diff --git a/tests/TestCase.php b/tests/TestCase.php index 2ae4b47d0..cde86b847 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,6 +6,8 @@ use MongoDB\BSON\Document; use MongoDB\BSON\PackedArray; use MongoDB\Codec\Codec; +use MongoDB\Codec\DecodeIfSupported; +use MongoDB\Codec\EncodeIfSupported; use MongoDB\Driver\ReadConcern; use MongoDB\Driver\ReadPreference; use MongoDB\Driver\WriteConcern; @@ -234,7 +236,34 @@ protected static function getInvalidObjectValues(bool $includeNull = false): arr protected static function getInvalidDocumentCodecValues(): array { - return [123, 3.14, 'foo', true, [], new stdClass(), self::createStub(Codec::class)]; + $codec = new class implements Codec { + use DecodeIfSupported; + use EncodeIfSupported; + + public function canDecode(mixed $value): bool + { + return true; + } + + public function decode(mixed $value): mixed + { + return $value; + } + + public function canEncode(mixed $value): bool + { + return true; + } + + public function encode(mixed $value): mixed + { + return $value; + } + }; + // @fixme: createStub can be called statically in PHPUnit 10 + // $codec = self::createStub(Codec::class); + + return [123, 3.14, 'foo', true, [], new stdClass(), $codec]; } /**