mageekguy\atoum\runner::setTestFactory PHP Method

setTestFactory() public method

public setTestFactory ( $testFactory = null )
    public function setTestFactory($testFactory = null)
    {
        $testFactory = $testFactory ?: function ($testClass) {
            return new $testClass();
        };
        $runner = $this;
        $this->testFactory = function ($testClass) use($testFactory, $runner) {
            $test = call_user_func($testFactory, $testClass);
            if ($runner->usageOfUndefinedMethodInMockAreAllowed() === false) {
                $test->getMockGenerator()->disallowUndefinedMethodUsage();
            }
            return $test;
        };
        return $this;
    }

Usage Example

コード例 #1
0
ファイル: runner.php プロジェクト: atoum/atoum
 public function testSetTestFactory()
 {
     $this->if($runner = new testedClass())->then->variable($runner->getTestFactory())->isCallable->object($runner->setTestFactory())->isIdenticalTo($runner)->object($runner->getTestFactory())->isCallable->if($factory = function () {
     })->then->object($runner->setTestFactory($factory))->isIdenticalTo($runner)->object($runner->getTestFactory())->isCallable->given($test = new \mock\mageekguy\atoum\test())->and($generator = new \mock\mageekguy\atoum\test\mock\generator($test))->and($test->setMockGenerator($generator))->if($runner->disallowUsageOfUndefinedMethodInMock())->and($runner->setTestFactory(function () use($test) {
         return $test;
     }))->and($factory = $runner->getTestFactory())->then->object($factory('mock\\mageekguy\\atoum\\test'))->isIdenticalTo($test)->mock($generator)->call('disallowUndefinedMethodUsage')->once->if($this->resetMock($generator))->if($runner->allowUsageOfUndefinedMethodInMock())->then->object($factory('mock\\mageekguy\\atoum\\test'))->isIdenticalTo($test)->mock($generator)->call('disallowUndefinedMethodUsage')->never;
 }
runner