@@ -27,31 +27,44 @@ static public function setUpBeforeClass()
27
27
public function setUp ()
28
28
{
29
29
$ this ->parser = new Parser ();
30
- $ this ->path = __DIR__ .'/Fixtures ' ;
31
30
}
32
31
33
- public function testSpecifications ()
32
+ /**
33
+ * @dataProvider getDataFormSpecifications
34
+ */
35
+ public function testSpecifications ($ expected , $ yaml , $ comment )
34
36
{
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 ' ));
36
47
foreach ($ files as $ file ) {
37
- $ yamls = file_get_contents ($ this -> path .'/ ' .$ file .'.yml ' );
48
+ $ yamls = file_get_contents ($ path .'/ ' .$ file .'.yml ' );
38
49
39
50
// split YAMLs documents
40
51
foreach (preg_split ('/^---( %YAML\:1\.0)?/m ' , $ yamls ) as $ yaml ) {
41
52
if (!$ yaml ) {
42
53
continue ;
43
54
}
44
55
45
- $ test = $ this -> parser ->parse ($ yaml );
56
+ $ test = $ parser ->parse ($ yaml );
46
57
if (isset ($ test ['todo ' ]) && $ test ['todo ' ]) {
47
58
// TODO
48
59
} else {
49
60
$ expected = var_export (eval ('return ' .trim ($ test ['php ' ]).'; ' ), true );
50
61
51
- $ this -> assertEquals ($ expected , var_export ( $ this -> parser -> parse ( $ test ['yaml ' ]), true ) , $ test ['test ' ]);
62
+ $ tests [] = array ($ expected , $ test ['yaml ' ], $ test ['test ' ]);
52
63
}
53
64
}
54
65
}
66
+
67
+ return $ tests ;
55
68
}
56
69
57
70
public function testTabsInYaml ()
0 commit comments