/** * @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(); }
public function setUp() { $this->executor = $this->getMockBuilder('Procrastinator\\Executor\\Executor')->getMock(); $this->decorator = new PhpFpmExecutorDecorator($this->executor); $this->executable = $this->getMockBuilder('Procrastinator\\Executable')->getMock(); $this->deferred = $this->getMockBuilder('Procrastinator\\Deferred\\Deferred')->getMock(); $this->functions = \PHPUnit_Extension_FunctionMocker::start($this, __NAMESPACE__)->mockFunction('function_exists')->mockFunction('fastcgi_finish_request')->getMock(); }
public function setUp() { $this->executor = $this->getMockBuilder('Procrastinator\\Executor\\Executor')->getMock(); $this->decorator = new SetTimeLimitDecorator($this->executor, 120); $this->executable = $this->getMockBuilder('Procrastinator\\Executable')->getMock(); $this->deferred = $this->getMockBuilder('Procrastinator\\Deferred\\Deferred')->getMock(); $this->functions = \PHPUnit_Extension_FunctionMocker::start($this, __NAMESPACE__)->mockFunction('set_time_limit')->getMock(); }
public function tearDown() { \PHPUnit_Extension_FunctionMocker::tearDown(); $fs = new Filesystem(); if ($fs->exists(PHPUNIT_WEBROOT . '/app/cache/config-cache.json')) { $fs->remove(PHPUNIT_WEBROOT . '/app/cache/config-cache.json'); } if ($fs->exists(PHPUNIT_WEBROOT . '/extensions/local/')) { $fs->remove(PHPUNIT_WEBROOT . '/extensions/local/'); } }
public function testMockSameFunctionIsDifferentNamespaces() { $this->assertMockFunctionNotDefined('My\\TestNamespace\\foofunc'); $this->functionMocker->mockFunction('foofunc'); $this->assertMockFunctionNotDefined('My\\TestNamespace\\foofunc'); $this->functionMocker->getMock(); $this->assertMockFunctionDefined('My\\TestNamespace\\foofunc', 'My\\TestNamespace'); $this->functionMocker = PHPUnit_Extension_FunctionMocker::start($this, 'My\\TestNamespace2'); $this->assertFalse(function_exists('My\\TestNamespace2\\foofunc')); $this->functionMocker->mockFunction('foofunc'); $this->assertFalse(function_exists('My\\TestNamespace2\\foofunc')); $this->functionMocker->getMock(); $this->assertMockFunctionDefined('My\\TestNamespace2\\foofunc', 'My\\TestNamespace2'); }
public function tearDown() { \PHPUnit_Extension_FunctionMocker::tearDown(); }
public function setUp() { $this->php = \PHPUnit_Extension_FunctionMocker::start($this, 'Bolt\\Twig\\Handler')->mockFunction('shuffle')->getMock(); }
public function tearDown() { \PHPUnit_Extension_FunctionMocker::tearDown(); @unlink(TEST_ROOT . '/app/cache/config_cache.php'); }
public function testMockingGlobalFunctionAndCallingOriginalAgain() { $this->testMocked(); PHPUnit_Extension_FunctionMocker::tearDown(); $this->assertSame(2, \PHPUnitTests\Extension\Fixtures\TestClass::invokeGlobalFunction()); }