/** * @group core */ public function testCeptNamings() { $cept = new \Codeception\Test\Cept('Login', 'tests/acceptance/LoginCept.php'); $this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\Test\Descriptor::getTestFileName($cept)); $this->assertEquals('tests/acceptance/LoginCept.php', \Codeception\Test\Descriptor::getTestFullName($cept)); $this->assertEquals('LoginCept', \Codeception\Test\Descriptor::getTestSignature($cept)); }
public function groupsForTest(\PHPUnit_Framework_Test $test) { $groups = []; $filename = Descriptor::getTestFileName($test); if ($test instanceof TestInterface) { $groups = $test->getMetadata()->getGroups(); } if ($test instanceof Reported) { $info = $test->getReportFields(); if (isset($info['class'])) { $groups = array_merge($groups, \PHPUnit_Util_Test::getGroups($info['class'], $info['name'])); } $filename = str_replace(['\\\\', '//'], ['\\', '/'], $info['file']); } if ($test instanceof \PHPUnit_Framework_TestCase) { $groups = array_merge($groups, \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false))); } foreach ($this->testsInGroups as $group => $tests) { foreach ($tests as $testPattern) { if ($filename == $testPattern) { $groups[] = $group; } if (strpos($filename . ':' . $test->getName(false), $testPattern) === 0) { $groups[] = $group; } } } return array_unique($groups); }
public function beforeTest(TestEvent $e) { $this->logger = new \Monolog\Logger(Descriptor::getTestFileName($e->getTest())); $this->logger->pushHandler($this->logHandler); $this->logger->info('------------------------------------'); $this->logger->info("STARTED: " . ucfirst(Descriptor::getTestAsString($e->getTest()))); }
/** * @group core */ public function testCestNamings() { $klass = new stdClass(); $cest = new \Codeception\Test\Cest($klass, 'user', 'tests/acceptance/LoginCest.php'); $this->assertEquals('tests/acceptance/LoginCest.php:user', \Codeception\Test\Descriptor::getTestFullName($cest)); $this->assertEquals('tests/acceptance/LoginCest.php', \Codeception\Test\Descriptor::getTestFileName($cest)); $this->assertEquals('stdClass:user', \Codeception\Test\Descriptor::getTestSignature($cest)); }
public function afterTest(TestEvent $e) { $test = new \stdClass(); $test->name = \Codeception\Test\Descriptor::getTestFileName($e->getTest()); // stack overflow: http://stackoverflow.com/questions/16825240/how-to-convert-microtime-to-hhmmssuu $seconds_input = $e->getTime(); $seconds = (int) ($milliseconds = (int) ($seconds_input * 1000)) / 1000; $time = $seconds % 60; $test->time = $time; self::$testTimes[] = $test; }
protected function enhancePhpunitTest(\PHPUnit_Framework_TestCase $test) { $className = get_class($test); $methodName = $test->getName(false); $dependencies = \PHPUnit_Util_Test::getDependencies($className, $methodName); $test->setDependencies($dependencies); if ($test instanceof UnitFormat) { $test->getMetadata()->setFilename(Descriptor::getTestFileName($test)); $test->getMetadata()->setDependencies($dependencies); $test->getMetadata()->setEnv(Annotation::forMethod($test, $methodName)->fetchAll('env')); } }
/** * @param \PHPUnit_Framework_SelfDescribing $test * @param bool $inProgress */ protected function writeCurrentTest(\PHPUnit_Framework_SelfDescribing $test, $inProgress = true) { $prefix = ($this->output->isInteractive() and !$this->isDetailed($test) and $inProgress) ? '- ' : ''; $atMessage = $this->message(' '); $filename = basename(Descriptor::getTestFileName($test)); if ($filename) { $atMessage = $atMessage->append($this->options['colors'] ? '' : 'at ')->append($filename); } $stripDataSet = function ($str) { return str_replace('with data set', "|", $str); }; if (!$test instanceof Descriptive) { $title = $this->message(str_replace('::', ':', $test->toString()))->apply($stripDataSet); $atMessage->cut($this->width - 4 - strlen($title))->style('info'); $this->message($title)->append($atMessage)->prepend($prefix)->write(); return; } $feature = $test->getName(true); if ($test instanceof TestInterface and $test->getMetadata()->getFeature()) { $feature = $test->getMetadata()->getFeature(); } $title = $this->message(ucfirst($feature))->apply($stripDataSet); $atMessage->cut($this->width - 4 - strlen($title))->style('info'); $this->message($title)->prepend($prefix)->append($atMessage)->write(); }