Skip to content

Commit

Permalink
createStub cannot be called statically with PHPUnit 9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Sep 13, 2024
1 parent 4ec4869 commit 21e944e
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}

/**
Expand Down

0 comments on commit 21e944e

Please sign in to comment.