コード例 #1
0
ファイル: ruler.php プロジェクト: atoum/ruler-extension
 /**
  * @dataProvider testFilterDataProvider
  */
 public function testIsMethodIgnored($case, $rules)
 {
     $test = new \mock\mageekguy\atoum\test();
     $test->getMockController()->getTestMethods = array_keys($case['methodTags']);
     $test->getMockController()->getClass = $case['class'];
     $test->getMockController()->getClassNamespace = $case['classNamespace'];
     $test->getMockController()->getTestedClassName = $case['testedClassName'];
     $test->getMockController()->getTestedClassNameNamespace = $case['testedClassNamespace'];
     $test->getMockController()->getMethodTags = $case['methodTags'];
     $test->getMockController()->getMandatoryMethodExtensions = $case['mandatoryMethodExtensions'];
     foreach ($rules as $rule => $methodCases) {
         $testedClass = new testedClass($rule);
         foreach ($methodCases as $methodName => $isIgnored) {
             $this->boolean($testedClass->isMethodIgnored($test, $methodName))->isEqualTo($isIgnored, sprintf("rule : '%s' method: '%s', expected : %s", $rule, $methodName, var_export($isIgnored, true)));
         }
     }
 }
コード例 #2
0
ファイル: concurrent.php プロジェクト: ronan-gloo/atoum
 public function testGetScore()
 {
     $this->if($engine = new engines\concurrent())->then->variable($engine->getScore())->isNull()->if($engine = new engines\concurrent())->and($engine->setAdapter($adapter = new atoum\test\adapter()))->and($engine->run($test = new \mock\mageekguy\atoum\test()))->then->variable($engine->getScore())->isNull()->if($test->getMockController()->getCurrentMethod = $method = uniqid())->and($test->getMockController()->getPath = $testPath = uniqid())->and($test->getMockController()->getPhpPath = $phpPath = uniqid())->and($test->getMockController()->codeCoverageIsEnabled = false)->and($test->getMockController()->getBootstrapFile = null)->and($adapter->proc_open = function ($command, array $descriptors, array &$pipes) use(&$resource, &$stdIn, &$stdOut, &$stdErr) {
         $pipes = array($stdIn = uniqid(), $stdOut = uniqid(), $stdErr = uniqid());
         return $resource = uniqid();
     })->and($adapter->proc_close = function () {
     })->and($adapter->proc_get_status = array('running' => true))->and($adapter->fwrite = function () {
     })->and($adapter->fclose = function () {
     })->and($adapter->stream_set_blocking = function () {
     })->and($adapter->stream_get_contents = $output = uniqid())->and($engine->run($test))->then->variable($engine->getScore())->isNull()->if($adapter->proc_get_status = array('running' => false, 'exitcode' => $exitCode = rand(1, PHP_INT_MAX)))->then->object($score = $engine->getScore())->isInstanceOf('mageekguy\\atoum\\score')->array($score->getUncompletedMethods())->isEqualTo(array(array('class' => get_class($test), 'method' => $method, 'exitCode' => $exitCode, 'output' => $output . $output)))->if($adapter->stream_get_contents = serialize($score))->and($engine->run($test))->then->object($score = $engine->getScore())->isEqualTo($score);
 }
コード例 #3
0
ファイル: cli.php プロジェクト: xihewang/atoum
 public function test__toString()
 {
     $this->if($score = new \mock\mageekguy\atoum\score())->and($score->getMockController()->getTotalMemoryUsage = $totalMemoryUsage = rand(0, PHP_INT_MAX))->and($adapter = new atoum\test\adapter())->and($adapter->class_exists = true)->and($testController = new atoum\mock\controller())->and($testController->getTestedClassName = uniqid())->and($test = new \mock\mageekguy\atoum\test($adapter))->and($test->getMockController()->getScore = $score)->and($defaultField = new test\memory\cli())->and($customField = new test\memory\cli())->and($customField->setPrompt($prompt = new prompt(uniqid())))->and($customField->setTitleColorizer($titleColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setMemoryColorizer($memoryColorizer = new colorizer(uniqid(), uniqid())))->and($customField->setLocale($locale = new locale()))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . $defaultField->getLocale()->_('Memory usage: unknown.') . PHP_EOL)->castToString($customField)->isEqualTo($prompt . sprintf($locale->_('%1$s: %2$s.'), $titleColorizer->colorize($locale->_('Memory usage')), $memoryColorizer->colorize($locale->_('unknown'))) . PHP_EOL)->if($defaultField->handleEvent(atoum\test::runStart, $test))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . $defaultField->getLocale()->_('Memory usage: unknown.') . PHP_EOL)->if($customField->handleEvent(atoum\test::runStart, $test))->then->castToString($customField)->isEqualTo($prompt . sprintf($locale->_('%1$s: %2$s.'), $titleColorizer->colorize($locale->_('Memory usage')), $memoryColorizer->colorize($locale->_('unknown'))) . PHP_EOL)->if($defaultField->handleEvent(atoum\test::runStop, $test))->then->castToString($defaultField)->isEqualTo($defaultField->getPrompt() . sprintf($defaultField->getLocale()->_('Memory usage: %4.2f Mb.'), $totalMemoryUsage / 1048576) . PHP_EOL)->if($customField->handleEvent(atoum\test::runStop, $test))->then->castToString($customField)->isEqualTo($prompt . sprintf($locale->_('%1$s: %2$s.'), $titleColorizer->colorize($locale->_('Memory usage')), $memoryColorizer->colorize(sprintf($locale->_('%4.2f Mb'), $totalMemoryUsage / 1048576))) . PHP_EOL);
 }
コード例 #4
0
 public function testSetTest()
 {
     $this->given($container = new ContainerBuilder(), $manager = new \mock\mageekguy\atoum\test\assertion\manager(), $test = new \mock\mageekguy\atoum\test(), $test->setAssertionManager($manager))->if($extension = new testedClass())->then->object($extension->setTest($test))->isIdenticalTo($extension)->mock($manager)->call('setHandler')->withArguments('containerBuilder')->once()->withArguments('serviceDefinition')->once();
 }
コード例 #5
0
ファイル: inline.php プロジェクト: ronan-gloo/atoum
 public function testGetScore()
 {
     $this->if($engine = new engines\inline())->then->object($engine->getScore())->isInstanceof('mageekguy\\atoum\\score')->if($test = new \mock\mageekguy\atoum\test())->and($test->getMockController()->getCurrentMethod = $method = uniqid())->and($test->getMockController()->runTestMethod = $test)->and($engine->run($test))->then->object($engine->getScore())->isInstanceOf('mageekguy\\atoum\\test\\score');
 }
コード例 #6
0
 public function testSetTest()
 {
     $this->if($extension = new testedClass())->and($test = new \mock\mageekguy\atoum\test())->and($manager = new \mock\mageekguy\atoum\test\assertion\manager())->and($test->setAssertionManager($manager))->then->object($extension->setTest($test))->isIdenticalTo($extension)->mock($manager)->call('setHandler')->withArguments('json')->once()->object($faker = $test->json('{}'))->isInstanceOf('mageekguy\\atoum\\jsonSchema\\asserters\\json');
 }
コード例 #7
0
 public function testSetTest()
 {
     $this->if($extension = new testedClass())->and($test = new \mock\mageekguy\atoum\test())->and($manager = new \mock\mageekguy\atoum\test\assertion\manager())->and($test->setAssertionManager($manager))->then->object($extension->setTest($test))->isIdenticalTo($extension)->mock($manager)->call('setHandler')->withArguments('blackfireProfile')->once();
 }
コード例 #8
0
ファイル: xunit.php プロジェクト: xihewang/atoum
 public function testBuild()
 {
     $this->if($adapter = new atoum\test\adapter())->and($adapter->extension_loaded = true)->and($adapter->get_class = $class = 'class')->and($runner = new atoum\runner())->and($score = new runner\score())->and($report = new reports\xunit($adapter))->and($runner->setScore($score))->and($testScore = new atoum\test\score())->and($testScore->addPass())->and($test = new \mock\mageekguy\atoum\test())->and($test->getMockController()->getCurrentMethod[1] = $method = 'method')->and($test->getMockController()->getCurrentMethod[2] = $otherMethod = 'otherMethod')->and($test->getMockController()->getCurrentMethod[3] = $thirdMethod = 'thirdMethod')->and($test->setScore($testScore))->and($path = join(DIRECTORY_SEPARATOR, array(__DIR__, 'xunit', 'resources')))->and($testScore->addDuration(uniqid(), $class, $method, $duration = 1))->and($testScore->addUncompletedMethod(uniqid(), $class, $otherMethod, $exitCode = 1, $output = 'output'))->and($testScore->addSkippedMethod(uniqid(), $class, $thirdMethod, $line = rand(1, PHP_INT_MAX), $message = 'message'))->and($report->handleEvent(atoum\test::afterTestMethod, $test))->and($testScore->addPass())->and($testScore->addPass())->and($report->handleEvent(atoum\test::afterTestMethod, $test))->and($report->handleEvent(atoum\test::afterTestMethod, $test))->and($score->merge($testScore))->and($report->handleEvent(atoum\runner::runStop, $runner))->then->castToString($report)->isEqualToContentsOfFile(join(DIRECTORY_SEPARATOR, array($path, '1.xml')))->if($adapter->get_class = $otherClass = 'otherClass')->and($test->setScore($testScore = new atoum\test\score()))->and($test->getMockController()->getCurrentMethod[4] = $otherMethod)->and($test->getMockController()->getCurrentMethod[5] = $thirdMethod)->and($testScore->addFail(uniqid(), $otherClass, $otherMethod, 1, $asserter = 'asserter', $reason = 'reason'))->and($exception = new \mock\Exception())->and($exception->getMockController()->__toString = $trace = 'trace')->and($testScore->addException(uniqid(), $otherClass, $thirdMethod, 1, $exception))->and($score->merge($testScore))->and($report->handleEvent(atoum\test::afterTestMethod, $test))->and($report->handleEvent(atoum\test::afterTestMethod, $test))->and($report->handleEvent(atoum\runner::runStop, $runner))->then->castToString($report)->isEqualToContentsOfFile(join(DIRECTORY_SEPARATOR, array($path, '2.xml')))->if($adapter->get_class = $thirdClassFqn = 'package\\thirdClass')->and($test->setScore($testScore = new atoum\test\score()))->and($test->getMockController()->getCurrentMethod[6] = $fourthMethod = 'fourthMethod')->and($testScore->addError(uniqid(), $thirdClassFqn, $fourthMethod, rand(0, PHP_INT_MAX), $type = E_ERROR, $message))->and($score->merge($testScore))->and($report->handleEvent(atoum\test::afterTestMethod, $test))->and($report->handleEvent(atoum\runner::runStop, $runner))->then->castToString($report)->isEqualToContentsOfFile(join(DIRECTORY_SEPARATOR, array($path, '3.xml')));
 }
コード例 #9
0
ファイル: xunit.php プロジェクト: atoum/reports-extension
 public function testBuild()
 {
     $this->if($adapter = new atoum\test\adapter())->and($adapter->extension_loaded = true)->and($adapter->get_class = $class = 'class')->and($runner = new atoum\runner())->and($score = new runner\score())->and($report = $this->newTestedInstance($adapter))->and($runner->setScore($score))->and($testScore = new atoum\test\score())->and($testScore->addPass())->and($test = new \mock\mageekguy\atoum\test())->and($test->getMockController()->getCurrentMethod[1] = $method = 'method')->and($test->getMockController()->getCurrentMethod[2] = $otherMethod = 'otherMethod')->and($test->getMockController()->getCurrentMethod[3] = $thirdMethod = 'thirdMethod')->and($test->setScore($testScore))->and($path = join(DIRECTORY_SEPARATOR, array(__DIR__, 'resources')))->and($testScore->addDuration('foo', $class, $method, $duration = 1))->and($testScore->addUncompletedMethod(uniqid(), $class, $otherMethod, $exitCode = 1, $output = 'output'))->and($testScore->addSkippedMethod(uniqid(), $class, $thirdMethod, $line = rand(1, PHP_INT_MAX), $message = 'message'))->and($report->handleEvent(atoum\test::afterTestMethod, $test))->and($testScore->addPass())->and($testScore->addPass())->and($report->handleEvent(atoum\test::afterTestMethod, $test))->and($report->handleEvent(atoum\test::afterTestMethod, $test))->and($score->merge($testScore))->and($report->handleEvent(atoum\runner::runStop, $runner))->then->castToString($report)->isEqualToContentsOfFile(join(DIRECTORY_SEPARATOR, array($path, '1.xml')))->object($dom = new \DomDocument())->boolean($dom->loadXML((string) $report))->isTrue()->boolean($dom->schemaValidate(join(DIRECTORY_SEPARATOR, array($path, 'xunit.xsd'))))->isTrue();
 }
コード例 #10
0
ファイル: concurrent.php プロジェクト: xihewang/atoum
 public function testRun()
 {
     $this->if($engine = new testedClass())->and($engine->setPhp($php = new \mock\mageekguy\atoum\php()))->then->object($engine->run($test = new \mock\mageekguy\atoum\test()))->isIdenticalTo($engine)->if($test->getMockController()->getCurrentMethod = $method = uniqid())->and($test->getMockController()->getPath = $testPath = uniqid())->and($test->getMockController()->getPhpPath = $phpPath = uniqid())->and($test->getMockController()->codeCoverageIsEnabled = false)->and($test->getMockController()->getBootstrapFile = null)->and($test->setXdebugConfig($xdebugConfig = uniqid()))->and($this->calling($php)->run->throw = $exception = new atoum\php\exception())->and($this->function->getenv = false)->and($this->function->ini_get = 0)->then->exception(function () use($engine, $test) {
         $engine->run($test);
     })->isIdenticalTo($exception)->if($this->calling($php)->run = $php)->then->object($engine->run($test))->isIdenticalTo($engine)->mock($php)->call('run')->withArguments('<?php ' . 'ob_start();' . 'require \'' . atoum\directory . '/classes/autoloader.php\';' . 'require \'' . $testPath . '\';' . '$test = new ' . get_class($test) . '();' . '$test->setLocale(new ' . get_class($test->getLocale()) . '(' . $test->getLocale()->get() . '));' . '$test->setPhpPath(\'' . $phpPath . '\');' . '$test->disableCodeCoverage();' . 'ob_end_clean();' . 'mageekguy\\atoum\\scripts\\runner::disableAutorun();' . 'echo serialize($test->runTestMethod(\'' . $method . '\')->getScore());')->twice()->call('__set')->withArguments('XDEBUG_CONFIG', $xdebugConfig)->twice();
 }
コード例 #11
0
 public function testSetTest()
 {
     $this->if($extension = new testedClass())->and($test = new \mock\mageekguy\atoum\test())->and($manager = new \mock\mageekguy\atoum\test\assertion\manager())->and($test->setAssertionManager($manager))->then->object($extension->setTest($test))->isIdenticalTo($extension);
 }