diff --git a/src/Stub.php b/src/Stub.php index ae31b40..d3a3fcc 100644 --- a/src/Stub.php +++ b/src/Stub.php @@ -9,7 +9,8 @@ use Codeception\Stub\StubMarshaler; use Exception; use LogicException; -use PHPUnit\Framework\MockObject\Generator; +use PHPUnit\Framework\MockObject\Generator as LegacyGenerator; +use PHPUnit\Framework\MockObject\Generator\Generator; use PHPUnit\Framework\MockObject\MockObject as PHPUnitMockObject; use PHPUnit\Framework\MockObject\Rule\AnyInvokedCount; use PHPUnit\Framework\MockObject\Stub\ConsecutiveCalls; @@ -433,7 +434,12 @@ private static function doGenerateMock($args, $isAbstract = false) { $testCase = self::extractTestCaseFromArgs($args); $methodName = $isAbstract ? 'getMockForAbstractClass' : 'getMock'; - $generatorClass = new Generator; + // PHPUnit 10.3 changed the namespace + if (version_compare(PHPUnitVersion::series(), '10.3', '>=')) { + $generatorClass = new Generator(); + } else { + $generatorClass = new LegacyGenerator(); + } // using PHPUnit 5.4 mocks registration if (version_compare(PHPUnitVersion::series(), '5.4', '>=') diff --git a/tests/StubTest.php b/tests/StubTest.php index 9325ad4..e56c3b3 100644 --- a/tests/StubTest.php +++ b/tests/StubTest.php @@ -387,12 +387,6 @@ public function testStubMakeEmptyInterface() $stub = Stub::makeEmpty(Countable::class, ['count' => 5]); $this->assertEquals(5, $stub->count()); } - - private function assertObjectHasProperty(string $propertyName, object $object): void - { - $hasProperty = (new ReflectionObject($object))->hasProperty($propertyName); - $this->assertTrue($hasProperty, sprintf("Object has no attribute %s", $propertyName)); - } } class MyClassWithPrivateProperties