Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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', '>=')
Expand Down
6 changes: 0 additions & 6 deletions tests/StubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down