11
11
use stdClass ;
12
12
use Symfony \Bridge \PhpUnit \SetUpTearDownTrait ;
13
13
use Throwable ;
14
- use function basename ;
15
14
use function file_get_contents ;
16
15
use function glob ;
17
16
use function MongoDB \BSON \fromJSON ;
@@ -119,7 +118,7 @@ public function testPassingTests(stdClass $test, string $schemaVersion, array $r
119
118
120
119
public function providePassingTests ()
121
120
{
122
- return $ this ->provideTests ('/home/jmikola/workspace/mongodb/specifications/source/unified-test-format/tests/valid-pass/ ' );
121
+ return $ this ->provideTests ('/home/jmikola/workspace/mongodb/specifications/source/unified-test-format/tests/valid-pass ' );
123
122
}
124
123
125
124
/**
@@ -150,7 +149,7 @@ private function provideTests(string $dir)
150
149
{
151
150
$ testArgs = [];
152
151
153
- foreach (glob ($ dir . '/poc-c *.json ' ) as $ filename ) {
152
+ foreach (glob ($ dir . '/*.json ' ) as $ filename ) {
154
153
/* Decode the file through the driver's extended JSON parser to
155
154
* ensure proper handling of special types. */
156
155
$ json = toPHP (fromJSON (file_get_contents ($ filename )));
@@ -160,9 +159,20 @@ private function provideTests(string $dir)
160
159
$ runOnRequirements = $ json ->runOnRequirements ?? null ;
161
160
$ createEntities = $ json ->createEntities ?? null ;
162
161
$ initialData = $ json ->initialData ?? null ;
162
+ $ tests = $ json ->tests ;
163
+
164
+ /* Assertions in data providers do not count towards test assertions
165
+ * but failures will interrupt the test suite with a warning. */
166
+ $ message = 'Invalid test file: ' . $ filename ;
167
+ $ this ->assertInternalType ('string ' , $ description , $ message );
168
+ $ this ->assertInternalType ('string ' , $ schemaVersion , $ message );
169
+ $ this ->assertInternalType ('array ' , $ tests , $ message );
163
170
164
171
foreach ($ json ->tests as $ test ) {
165
- $ name = basename ($ filename ) . ': ' . $ description . ': ' . $ test ->description ;
172
+ $ this ->assertInternalType ('object ' , $ test , $ message );
173
+ $ this ->assertInternalType ('string ' , $ test ->description , $ message );
174
+
175
+ $ name = $ description . ': ' . $ test ->description ;
166
176
$ testArgs [$ name ] = [$ test , $ schemaVersion , $ runOnRequirements , $ createEntities , $ initialData ];
167
177
}
168
178
}
0 commit comments