Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

derrabus
Copy link
Member

PHPUnit has deprecated partial mocking, so we should avoud calling getMockForAbstractClass() in our tests.

@derrabus derrabus force-pushed the improvement/phpunit-partial-mocks branch from 2c7607d to d2cbab2 Compare June 17, 2025 21:39

This comment was marked as resolved.

@github-actions github-actions bot added the Stale label Sep 16, 2025
@derrabus derrabus force-pushed the improvement/phpunit-partial-mocks branch 2 times, most recently from 6a20f49 to a308fec Compare September 16, 2025 06:49
@derrabus derrabus removed the Stale label Sep 16, 2025
@derrabus derrabus requested a review from greg0ire September 16, 2025 07:57
@derrabus derrabus force-pushed the improvement/phpunit-partial-mocks branch from a308fec to c2cdb52 Compare September 16, 2025 07:59
@derrabus derrabus added this to the 2.20.7 milestone Sep 16, 2025
$sqlExecMock->expects(self::once())
->method('execute')
->willReturn(10);
$sqlExecMock = new class extends AbstractSqlExecutor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer a mock… should it be renamed to include stub or dummy?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion here… What do you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say stub

$strategy = new DefaultQuoteStrategy();
$platform = $this->getMockForAbstractClass(AbstractPlatform::class);
assert($platform instanceof AbstractPlatform);
$platform = $this->createMock(AbstractPlatform::class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have a polyfill for createStub in DoctrineTestCase, let's use it, here and below?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants