2
2
3
3
namespace MongoDB \Tests \UnifiedSpecTests ;
4
4
5
+ use Exception ;
5
6
use MongoDB \Client ;
6
7
use MongoDB \Collection ;
7
8
use MongoDB \Driver \Exception \ServerException ;
11
12
use MongoDB \Tests \FunctionalTestCase ;
12
13
use stdClass ;
13
14
use Symfony \Bridge \PhpUnit \SetUpTearDownTrait ;
14
- use Throwable ;
15
15
use function file_get_contents ;
16
16
use function gc_collect_cycles ;
17
17
use function glob ;
@@ -87,10 +87,7 @@ private function doTearDown()
87
87
parent ::tearDown ();
88
88
}
89
89
90
- /**
91
- * @dataProvider providePassingTests
92
- */
93
- public function testPassingTests (stdClass $ test , string $ schemaVersion , array $ runOnRequirements = null , array $ createEntities = null , array $ initialData = null )
90
+ private function doTestCase (stdClass $ test , string $ schemaVersion , array $ runOnRequirements = null , array $ createEntities = null , array $ initialData = null )
94
91
{
95
92
if (! $ this ->isSchemaVersionSupported ($ schemaVersion )) {
96
93
$ this ->markTestIncomplete (sprintf ('Test format schema version "%s" is not supported ' , $ schemaVersion ));
@@ -144,6 +141,14 @@ public function testPassingTests(stdClass $test, string $schemaVersion, array $r
144
141
}
145
142
}
146
143
144
+ /**
145
+ * @dataProvider providePassingTests
146
+ */
147
+ public function testPassingTests (...$ args )
148
+ {
149
+ $ this ->doTestCase (...$ args );
150
+ }
151
+
147
152
public function providePassingTests ()
148
153
{
149
154
return $ this ->provideTests (__DIR__ . '/valid-pass ' );
@@ -157,11 +162,13 @@ public function testFailingTests(...$args)
157
162
// Cannot use expectException(), as it ignores PHPUnit Exceptions
158
163
$ failed = false ;
159
164
165
+ // phpcs:disable SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException
160
166
try {
161
- $ this ->testCase (...$ args );
162
- } catch (Throwable $ e ) {
167
+ $ this ->doTestCase (...$ args );
168
+ } catch (Exception $ e ) {
163
169
$ failed = true ;
164
170
}
171
+ // phpcs:enable
165
172
166
173
assertTrue ($ failed , 'Expected test to throw an exception ' );
167
174
}
0 commit comments