diff --git a/composer.json b/composer.json index 23651e3..c2c867b 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ }, "require": { "php": "^7.4 | ^8.0", - "phpunit/phpunit": "^8.4 | ^9.0 | ^10.0 | ^11" + "phpunit/phpunit": "^8.4 | ^9.0 | ^10.0 | ^11 | ^12" }, "require-dev": { "consolidation/robo": "^3.0" diff --git a/src/Stub.php b/src/Stub.php index d57db23..d9ce9dd 100644 --- a/src/Stub.php +++ b/src/Stub.php @@ -416,7 +416,11 @@ public static function constructEmptyExcept( private static function generateMock() { $args = func_get_args(); - if (version_compare(PHPUnitVersion::series(), '11', '>=')) { + // PHPUnit 11 added the optional parameter $markAsMockObject: + // https://github.com/sebastianbergmann/phpunit/commit/db9ae302fe1ad89451ecfacc850e88ab7c6df5a3 + // The parameter was removed in PHPUnit 12: + // https://github.com/sebastianbergmann/phpunit/commit/a98e3939c74f6103cbeb7a785b73eb4a10784474 + if (version_compare(PHPUnitVersion::series(), '11', '>=') && version_compare(PHPUnitVersion::series(), '12', '<')) { if (!is_bool($args[1]) || !is_bool($args[2])) { $additionalParameters = []; if (!is_bool($args[1])) { diff --git a/tests/StubTest.php b/tests/StubTest.php index d763b95..3b947df 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -6,6 +6,7 @@ use Codeception\Stub; use Codeception\Stub\StubMarshaler; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\NoMoreReturnValuesConfiguredException; use PHPUnit\Framework\TestCase; @@ -231,6 +232,7 @@ public static function matcherAndFailMessageProvider(): array /** * @dataProvider matcherAndFailMessageProvider */ + #[DataProvider('matcherAndFailMessageProvider')] public function testExpectedMethodIsCalledFail(StubMarshaler $stubMarshaler, string $failMessage) { $mock = Stub::makeEmptyExcept('DummyClass', 'call', ['targetMethod' => $stubMarshaler], $this); @@ -282,6 +284,7 @@ public static function matcherProvider(): array /** * @dataProvider matcherProvider */ + #[DataProvider('matcherProvider')] public function testMethodMatcherWithMake(int $count, StubMarshaler $matcher, $expected = false) { $dummy = Stub::make('DummyClass', ['goodByeWorld' => $matcher], $this); @@ -292,6 +295,7 @@ public function testMethodMatcherWithMake(int $count, StubMarshaler $matcher, $e /** * @dataProvider matcherProvider */ + #[DataProvider('matcherProvider')] public function testMethodMatcherWithMakeEmpty(int $count, StubMarshaler $matcher) { $dummy = Stub::makeEmpty('DummyClass', ['goodByeWorld' => $matcher], $this); @@ -302,6 +306,7 @@ public function testMethodMatcherWithMakeEmpty(int $count, StubMarshaler $matche /** * @dataProvider matcherProvider */ + #[DataProvider('matcherProvider')] public function testMethodMatcherWithMakeEmptyExcept(int $count, StubMarshaler $matcher) { $dummy = Stub::makeEmptyExcept('DummyClass', 'getCheckMe', ['goodByeWorld' => $matcher], $this); @@ -312,6 +317,7 @@ public function testMethodMatcherWithMakeEmptyExcept(int $count, StubMarshaler $ /** * @dataProvider matcherProvider */ + #[DataProvider('matcherProvider')] public function testMethodMatcherWithConstruct(int $count, StubMarshaler $matcher) { $dummy = Stub::construct('DummyClass', [], ['goodByeWorld' => $matcher], $this); @@ -322,6 +328,7 @@ public function testMethodMatcherWithConstruct(int $count, StubMarshaler $matche /** * @dataProvider matcherProvider */ + #[DataProvider('matcherProvider')] public function testMethodMatcherWithConstructEmpty(int $count, StubMarshaler $matcher) { $dummy = Stub::constructEmpty('DummyClass', [], ['goodByeWorld' => $matcher], $this); @@ -332,6 +339,7 @@ public function testMethodMatcherWithConstructEmpty(int $count, StubMarshaler $m /** * @dataProvider matcherProvider */ + #[DataProvider('matcherProvider')] public function testMethodMatcherWithConstructEmptyExcept(int $count, StubMarshaler $matcher) { $dummy = Stub::constructEmptyExcept(