Skip to content

Commit 1cd5939

Browse files
committed
[Yaml] refactored tests
1 parent 53847ca commit 1cd5939

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

tests/Symfony/Tests/Components/Yaml/ParserTest.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,44 @@ static public function setUpBeforeClass()
2727
public function setUp()
2828
{
2929
$this->parser = new Parser();
30-
$this->path = __DIR__.'/Fixtures';
3130
}
3231

33-
public function testSpecifications()
32+
/**
33+
* @dataProvider getDataFormSpecifications
34+
*/
35+
public function testSpecifications($expected, $yaml, $comment)
3436
{
35-
$files = $this->parser->parse(file_get_contents($this->path.'/index.yml'));
37+
$this->assertEquals($expected, var_export($this->parser->parse($yaml), true), $comment);
38+
}
39+
40+
public function getDataFormSpecifications()
41+
{
42+
$parser = new Parser();
43+
$path = __DIR__.'/Fixtures';
44+
45+
$tests = array();
46+
$files = $parser->parse(file_get_contents($path.'/index.yml'));
3647
foreach ($files as $file) {
37-
$yamls = file_get_contents($this->path.'/'.$file.'.yml');
48+
$yamls = file_get_contents($path.'/'.$file.'.yml');
3849

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

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

51-
$this->assertEquals($expected, var_export($this->parser->parse($test['yaml']), true), $test['test']);
62+
$tests[] = array($expected, $test['yaml'], $test['test']);
5263
}
5364
}
5465
}
66+
67+
return $tests;
5568
}
5669

5770
public function testTabsInYaml()

0 commit comments

Comments
 (0)