/** * Create new instance of the class, using PHP absolute file name * * @param $label string ID of the suite, its label * @param $runner phpRack_Runner Instance of test runner * @return phpRack_Suite * @throws phpRack_Exception * @see _addSuite() * @see phpRack_Runner::getTests() */ public static function factory($label, phpRack_Runner $runner) { $fileName = $runner->getDir() . '/' . $label; if (!file_exists($fileName)) { throw new phpRack_Exception("File '{$fileName}' is not found"); } if (!preg_match(phpRack_Runner::SUITE_PATTERN, $fileName)) { throw new phpRack_Exception("File '{$fileName}' is not named properly, can't run it"); } $className = pathinfo($fileName, PATHINFO_FILENAME); // workaround against ZCA static code analysis eval('require_once $fileName;'); return new $className($runner); }
/** * Get label of the test * * @return string */ public function getLabel() { return ltrim(substr($this->_fileName, strlen($this->_runner->getDir())), '/'); }