public function run(\PHPUnit_Framework_TestResult $result = null) { if (!$result) { $result = new \PHPUnit_Framework_TestResult(); } $reader = new \Fulfil\Test\SpecTest\Reader(); $tests = $reader->read($testFile); foreach ($tests as $test) { foreach ($test->data as $case) { \PHP_Timer::start(); $result->startTest($this); try { $ctx = new \Fulfil\Context(); $test->test->apply($case->in, $ctx); $flat = $ctx->flatten(); } catch (\Exception $ex) { // yum } $time = \PHP_Timer::stop(); try { \PHPUnit_Framework_Assert::assertEquals($case->valid, $flat->valid); } catch (\PHPUnit_Framework_AssertionFailedError $e) { $result->addFailure($this, $e, $time); } $result->endTest($this, $time); } } return $result; }
function specFileIterator() { $reader = new \Fulfil\Test\SpecTest\Reader(); foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(FULFIL_BASE_PATH . '/test/spec'), \RecursiveIteratorIterator::LEAVES_ONLY) as $item) { $name = $item->getFilename(); if ($item->isDir() || $name[0] == '.') { continue; } $testFile = $item->getPathname(); $tests = $reader->read($testFile); (yield [$testFile, $tests]); } }