Exemplo n.º 1
0
 /**
  * @param \mageekguy\atoum\test\score $score
  *
  * @return \mageekguy\atoum\test\score
  */
 public function rescore(\mageekguy\atoum\test\score $score)
 {
     foreach ($score->getErrors() as $key => $error) {
         if (!($error['type'] & E_USER_DEPRECATED)) {
             continue;
         }
         $score->deleteError($key);
         $this->errors[] = $error;
     }
 }
Exemplo n.º 2
0
 /**
  * @param \mageekguy\atoum\test\score $score
  *
  * @return \mageekguy\atoum\test\score
  */
 public function rescore(\mageekguy\atoum\test\score $score)
 {
     foreach ($score->getErrors() as $key => $error) {
         if (!($error['type'] & E_USER_DEPRECATED)) {
             continue;
         }
         $score->deleteError($key);
         $score->addOutput($error['file'], $error['class'], $error['method'], $error["message"]);
     }
     return $score;
 }
Exemplo n.º 3
0
 protected function getCleanedScore(\mageekguy\atoum\test\score $score)
 {
     $newScore = new \mageekguy\atoum\test\score();
     $newScore->getCoverage($score->getCoverage());
     foreach ($score->getDurations() as $duration) {
         $newScore->addDuration($duration['path'], $duration['class'], $duration['method'], $duration['value']);
     }
     foreach ($score->getMemoryUsages() as $memoryUsage) {
         $newScore->addMemoryUsage(null, $memoryUsage['class'], $memoryUsage['method'], $memoryUsage['value']);
     }
     $assertions = $score->getPassNumber() + $score->getFailNumber();
     for ($i = 0; $i <= $assertions; $i++) {
         $newScore->addPass();
     }
     return $newScore;
 }
Exemplo n.º 4
0
 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')));
 }
Exemplo n.º 5
0
 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();
 }
Exemplo n.º 6
0
 public function testUnsetDataSet()
 {
     $this->if($score = new testedClass())->then->object($score->unsetDataSet())->isIdenticalTo($score)->variable($score->getDataSetKey())->isNull()->variable($score->getDataSetProvider())->isNull()->if($score->setDataSet(rand(1, PHP_INT_MAX), uniqid()))->then->object($score->unsetDataSet())->isIdenticalTo($score)->variable($score->getDataSetKey())->isNull()->variable($score->getDataSetProvider())->isNull();
 }