/** * Prepares a test to be run. This method executes before setUp. * * @param Spec\TestCaseInterface $test */ public function prepareTest(Spec\TestCaseInterface $test) { $ann = $test->annotations; /* @todo Shouldn't this be already done by PHPUnit if (!empty($ann['outputBuffering'])) { $enabled = filter_var($ann['outputBuffering'][0], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); $test->setUseOutputBuffering($enabled); } if (!empty($ann['errorHandler'])) { $enabled = filter_var($ann['errorHandler'][0], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); $test->setUseErrorHandler($enabled); } */ // Check @throws annotation // @todo can this be moved to setUp so it overrides PHPUnit annotations? if (!empty($ann['throws'])) { $regexp = '/([:.\\w\\\\x7f-\\xff]+)(?:[\\t ]+(\\S*))?(?:[\\t ]+(\\S*))?\\s*$/'; if (preg_match($regexp, $ann['throws'][0], $m)) { $class = $code = $message = null; if (is_numeric($m[1])) { $code = $m[1]; } else { $class = $m[1]; } $message = isset($m[2]) ? $m[2] : null; $code = isset($m[3]) ? (int) $m[3] : $code; $test->setExpectedException($class, $message, $code); } } // Register the current test case as the active one Spec::test($test); }