[Yaml] refactored tests
This commit is contained in:
parent
53847ca90c
commit
1cd5939e9a
@ -27,14 +27,25 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->parser = new Parser();
|
$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) {
|
foreach ($files as $file) {
|
||||||
$yamls = file_get_contents($this->path.'/'.$file.'.yml');
|
$yamls = file_get_contents($path.'/'.$file.'.yml');
|
||||||
|
|
||||||
// split YAMLs documents
|
// split YAMLs documents
|
||||||
foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
|
foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
|
||||||
@ -42,16 +53,18 @@ class ParserTest extends \PHPUnit_Framework_TestCase
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$test = $this->parser->parse($yaml);
|
$test = $parser->parse($yaml);
|
||||||
if (isset($test['todo']) && $test['todo']) {
|
if (isset($test['todo']) && $test['todo']) {
|
||||||
// TODO
|
// TODO
|
||||||
} else {
|
} else {
|
||||||
$expected = var_export(eval('return '.trim($test['php']).';'), true);
|
$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()
|
public function testTabsInYaml()
|
||||||
|
Reference in New Issue
Block a user