extracting native functions and wrapping them inside another class

Another approach would be removing the direct call to native functions and replace it with a wrapper class.

class NativeWrapper
{
    public function time()
    {
        return time();
    }
}
class Timer
{
    public function __construct($nativeWrapper)
    {
        $this->wapper = $nativeWrapper;
    }
    public function getCurrentTime()
    {
        return $this->wrapper->time();
    }
}

Then, in your test you can mock the wrapper object and force it to return the value you want:

public function testGetCurrentTime()
{
    $wrapper = $this->getMock('NativeWrapper', array('time'));
    $wrapper->expects($this->any())->method('time')->willReturn(123);
    
    $timer = new Timer($wrapper);
    $result = $timer->getCurrentTime(); // 123
}

This is very effective, but it's tedious to setup: you have to replace all the calls to native functions with wrapper class ones, moreover you have to heavily refactor your code in order to pass around such wrapper.