public function testUnknownTag() { $config = new TestSuite(); $config->setBaseDir(__DIR__ . '/fixtures/'); $configYaml = new Yaml(__DIR__ . '/fixtures/badtestsuite.yml'); $parser = new Parser('LiveTest\\Config\\Tags\\TestSuite\\'); $this->setExpectedException('LiveTest\\Config\\Parser\\UnknownTagException'); $parsedConfig = $parser->parse($configYaml->toArray(), $config); }
/** * Creates a properties object that was created using a yaml file. * * @todo is this method neccessary? If yes: Where to put it? At the moment it is only used to make testing easier * * @param String $filename The file name of the yaml file * @param Uri $defaultUri The default uri */ public static function createByYamlFile($filename, Uri $defaultUri, Dispatcher $eventDispatcher) { try { $yamlConfig = new Yaml($filename); } catch (\Zend\Config\Exception $e) { throw new ConfigurationException('Unable to load test suite yaml file (filename: ' . $filename . ')'); } $testSuiteConfig = new TestSuite(); $testSuiteConfig->setBaseDir(dirname($filename)); $testSuiteConfig->setDefaultDomain($defaultUri); $parser = new Parser('LiveTest\\Config\\Tags\\TestSuite\\'); try { $testSuiteConfig = $parser->parse($yamlConfig->toArray(), $testSuiteConfig); } catch (UnknownTagException $e) { throw new ConfigurationException('Error parsing testsuite configuration (' . $filename . '): ' . $e->getMessage(), null, $e); } $testSuiteConfig->resolveSessionGroups(); $eventDispatcher->simpleNotify('LiveTest.TestRun.Properties.PostTestSuiteInit', array('config' => $testSuiteConfig)); return new self($testSuiteConfig, $defaultUri); }
/** * This function parses the config array and returns a config object. This config * object can be handled by the event dispatcher. * @param array $configArray * @return ConfigConfig */ private function parseConfig($configArray) { $config = new ConfigConfig(); $parser = new Parser('\\LiveTest\\Config\\Tags\\Config\\'); try { $config = $parser->parse($configArray, $config); } catch (\LiveTest\Config\Parser\UnknownTagException $e) { throw new ConfigurationException('Unknown tag ("' . $e->getTagName() . '") found in the configuration file.', null, $e); } return $config; }