Esempio n. 1
0
Yaml::setSpecVersion('1.1');
$t = new LimeTest(148);
$parser = new Parser();
$path = __DIR__ . '/../../../../fixtures/Symfony/Components/Yaml';
$files = $parser->parse(file_get_contents($path . '/index.yml'));
foreach ($files as $file) {
    $t->diag($file);
    $yamls = file_get_contents($path . '/' . $file . '.yml');
    // split YAMLs documents
    foreach (preg_split('/^---( %YAML\\:1\\.0)?/m', $yamls) as $yaml) {
        if (!$yaml) {
            continue;
        }
        $test = $parser->parse($yaml);
        if (isset($test['todo']) && $test['todo']) {
            $t->todo($test['test']);
        } else {
            $expected = var_export(eval('return ' . trim($test['php']) . ';'), true);
            $t->is(var_export($parser->parse($test['yaml']), true), $expected, $test['test']);
        }
    }
}
// test tabs in YAML
$yamls = array("foo:\n\tbar", "foo:\n \tbar", "foo:\n\t bar", "foo:\n \t bar");
foreach ($yamls as $yaml) {
    try {
        $content = $parser->parse($yaml);
        $t->fail('YAML files must not contain tabs');
    } catch (ParserException $e) {
        $t->pass('YAML files must not contain tabs');
    }