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 @@ -159,12 +159,17 @@ final public static function provideInvalidStringValues(): array
159
159
}
160
160
161
161
protected function assertDeprecated (callable $ execution ): void
162
+ {
163
+ $ this ->assertError (E_USER_DEPRECATED , $ execution );
164
+ }
165
+
166
+ protected function assertError (int $ levels , callable $ execution ): void
162
167
{
163
168
$ errors = [];
164
169
165
170
set_error_handler (function ($ errno , $ errstr ) use (&$ errors ): void {
166
171
$ errors [] = $ errstr ;
167
- }, E_USER_DEPRECATED );
172
+ }, $ levels );
168
173
169
174
try {
170
175
call_user_func ($ execution );
You can’t perform that action at this time.
0 commit comments