PHPUnit_Extension_FunctionMocker::start PHP Method

start() public static method

Example: PHP global namespace function setcookie() needs to be overridden in order to test if a cookie gets set. When setcookie() is called from inside a class in the namespace \Foo\Bar the mock setcookie() created here will be used instead to the real function.
public static start ( PHPUnit_Framework_TestCase $testCase, string $namespace ) : PHPUnit_Extension_FunctionMocker
$testCase PHPUnit_Framework_TestCase
$namespace string
return PHPUnit_Extension_FunctionMocker
    public static function start(PHPUnit_Framework_TestCase $testCase, $namespace)
    {
        return new static($testCase, $namespace);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @runInSeparateProcess
  * @expectedException \RuntimeException
  */
 public function testRandomWithFailure()
 {
     $this->php = FunctionMocker::start($this, 'Chromabits\\Nucleus\\Support')->mockFunction('function_exists')->mockFunction('openssl_random_pseudo_bytes')->getMock();
     $this->php->expects($this->once())->method('function_exists')->will($this->returnValue(true));
     $this->php->expects($this->once())->method('openssl_random_pseudo_bytes')->will($this->returnValue(false));
     Str::random();
 }
All Usage Examples Of PHPUnit_Extension_FunctionMocker::start