@@ -11,17 +11,27 @@ abstract class BaseDraftTestCase extends BaseTestCase
11
11
private function setUpTests ($ isValid )
12
12
{
13
13
$ filePaths = $ this ->getFilePaths ();
14
- $ skippedTests = $ this ->getSkippedTests ();
14
+ $ whiteList = $ this ->getWhiteList ();
15
+ $ blackList = $ this ->getBlackList ();
15
16
$ tests = array ();
16
17
17
18
foreach ($ filePaths as $ path ) {
18
19
foreach (glob ($ path . '/*.json ' ) as $ file ) {
19
- if (!in_array (basename ($ file ), $ skippedTests )) {
20
+ $ name = basename ($ file );
21
+ $ whiteListed = $ whiteList && in_array ($ name , $ whiteList );
22
+ $ blackListed = !$ whiteList && $ blackList && in_array ($ name , $ blackList );
23
+ $ mustSkip = $ whiteList && !$ whiteListed || $ blackListed ;
24
+
25
+ if (!$ mustSkip ) {
20
26
$ suites = json_decode (file_get_contents ($ file ));
27
+
21
28
foreach ($ suites as $ suite ) {
22
29
foreach ($ suite ->tests as $ test ) {
23
30
if ($ isValid === $ test ->valid ) {
24
- $ tests [] = array (json_encode ($ test ->data ), json_encode ($ suite ->schema ));
31
+ $ tests [] = array (
32
+ json_encode ($ test ->data ),
33
+ json_encode ($ suite ->schema )
34
+ );
25
35
}
26
36
}
27
37
}
@@ -44,5 +54,26 @@ public function getValidTests()
44
54
45
55
protected abstract function getFilePaths ();
46
56
47
- protected abstract function getSkippedTests ();
57
+ /**
58
+ * Returns the list of tests to run, or false, if all
59
+ * the tests must be included in the suite by default.
60
+ *
61
+ * @return false|string[]
62
+ */
63
+ protected function getWhiteList ()
64
+ {
65
+ return false ;
66
+ }
67
+
68
+ /**
69
+ * Returns the list of tests not to run, or false, if no test
70
+ * should be excluded from the suite by default. Note that
71
+ * this list is ignored if a white list has been provided.
72
+ *
73
+ * @return false|string[]
74
+ */
75
+ protected function getBlackList ()
76
+ {
77
+ return false ;
78
+ }
48
79
}
0 commit comments