Skip to content

Commit

Permalink
[Yaml] refactored tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 29, 2010
1 parent 53847ca commit 1cd5939
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions tests/Symfony/Tests/Components/Yaml/ParserTest.php
Expand Up @@ -27,31 +27,44 @@ static public function setUpBeforeClass()
public function setUp()
{
$this->parser = new Parser();
$this->path = __DIR__.'/Fixtures';
}

public function testSpecifications()
/**
* @dataProvider getDataFormSpecifications
*/
public function testSpecifications($expected, $yaml, $comment)
{
$files = $this->parser->parse(file_get_contents($this->path.'/index.yml'));
$this->assertEquals($expected, var_export($this->parser->parse($yaml), true), $comment);
}

public function getDataFormSpecifications()
{
$parser = new Parser();
$path = __DIR__.'/Fixtures';

$tests = array();
$files = $parser->parse(file_get_contents($path.'/index.yml'));
foreach ($files as $file) {
$yamls = file_get_contents($this->path.'/'.$file.'.yml');
$yamls = file_get_contents($path.'/'.$file.'.yml');

// split YAMLs documents
foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
if (!$yaml) {
continue;
}

$test = $this->parser->parse($yaml);
$test = $parser->parse($yaml);
if (isset($test['todo']) && $test['todo']) {
// TODO
} else {
$expected = var_export(eval('return '.trim($test['php']).';'), true);

$this->assertEquals($expected, var_export($this->parser->parse($test['yaml']), true), $test['test']);
$tests[] = array($expected, $test['yaml'], $test['test']);
}
}
}

return $tests;
}

public function testTabsInYaml()
Expand Down

0 comments on commit 1cd5939

Please sign in to comment.