File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change 13
13
14
14
use const E_DEPRECATED ;
15
15
use const E_USER_DEPRECATED ;
16
+ use const E_USER_WARNING ;
16
17
17
18
class CodecCursorFunctionalTest extends FunctionalTestCase
18
19
{
@@ -30,10 +31,7 @@ public function testSetTypeMap(): void
30
31
31
32
$ codecCursor = CodecCursor::fromCursor ($ cursor , $ this ->createMock (DocumentCodec::class));
32
33
33
- $ this ->expectWarning ();
34
- $ this ->expectExceptionMessage ('Discarding type map for MongoDB\Model\CodecCursor::setTypeMap ' );
35
-
36
- $ codecCursor ->setTypeMap (['root ' => 'array ' ]);
34
+ $ this ->assertError (E_USER_WARNING , fn () => $ codecCursor ->setTypeMap (['root ' => 'array ' ]));
37
35
}
38
36
39
37
public function testGetIdReturnTypeWithoutArgument (): void
Original file line number Diff line number Diff line change @@ -160,12 +160,17 @@ final public static function provideInvalidStringValues(): array
160
160
}
161
161
162
162
protected function assertDeprecated (callable $ execution )
163
+ {
164
+ $ this ->assertError (E_USER_DEPRECATED | E_DEPRECATED , $ execution );
165
+ }
166
+
167
+ protected function assertError (int $ levels , callable $ execution ): void
163
168
{
164
169
$ errors = [];
165
170
166
171
set_error_handler (function ($ errno , $ errstr ) use (&$ errors ): void {
167
172
$ errors [] = $ errstr ;
168
- }, E_USER_DEPRECATED | E_DEPRECATED );
173
+ }, $ levels );
169
174
170
175
try {
171
176
$ result = call_user_func ($ execution );
You can’t perform that action at this time.
0 commit comments