Skip to content

Commit 21e944e

Browse files
committed
createStub cannot be called statically with PHPUnit 9.6
1 parent 4ec4869 commit 21e944e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

tests/TestCase.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
use MongoDB\BSON\Document;
77
use MongoDB\BSON\PackedArray;
88
use MongoDB\Codec\Codec;
9+
use MongoDB\Codec\DecodeIfSupported;
10+
use MongoDB\Codec\EncodeIfSupported;
911
use MongoDB\Driver\ReadConcern;
1012
use MongoDB\Driver\ReadPreference;
1113
use MongoDB\Driver\WriteConcern;
@@ -234,7 +236,34 @@ protected static function getInvalidObjectValues(bool $includeNull = false): arr
234236

235237
protected static function getInvalidDocumentCodecValues(): array
236238
{
237-
return [123, 3.14, 'foo', true, [], new stdClass(), self::createStub(Codec::class)];
239+
$codec = new class implements Codec {
240+
use DecodeIfSupported;
241+
use EncodeIfSupported;
242+
243+
public function canDecode(mixed $value): bool
244+
{
245+
return true;
246+
}
247+
248+
public function decode(mixed $value): mixed
249+
{
250+
return $value;
251+
}
252+
253+
public function canEncode(mixed $value): bool
254+
{
255+
return true;
256+
}
257+
258+
public function encode(mixed $value): mixed
259+
{
260+
return $value;
261+
}
262+
};
263+
// @fixme: createStub can be called statically in PHPUnit 10
264+
// $codec = self::createStub(Codec::class);
265+
266+
return [123, 3.14, 'foo', true, [], new stdClass(), $codec];
238267
}
239268

240269
/**

0 commit comments

Comments
 (0)