Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with PHPUnit error expectations #6469

Merged
merged 2 commits into from
Jun 16, 2022

Conversation

Naktibalda
Copy link
Member

Replaces #6461

@calvinalkan
Copy link
Contributor

@Naktibalda Can we release a 4.2 version once this is merged? Together with the other PRs merged lately.

@Naktibalda
Copy link
Member Author

that's the plan.

@Naktibalda Naktibalda merged commit 29df192 into 4.2 Jun 16, 2022
@Naktibalda Naktibalda deleted the error-handling-expectations branch June 16, 2022 04:59
@Naktibalda
Copy link
Member Author

@calvinalkan Most likely this functionality won't work with PHPUnit 10, unless we implement error expectations in Codeception\Test\Unit but in that case it will be limited to tests extending Codeception\Test\Unit.

See sebastianbergmann/phpunit@d4b3d9d

@Naktibalda
Copy link
Member Author

We can't override expectNotice and other methods in Unit class, because they are declared as final in TestCase.
If this functionality is important, we will have to use different method names.

Emitting PHPUnit event is not an option too, because it fixes expect functionality, but unexpected errors won't be reported by Codeception.

@calvinalkan
Copy link
Contributor

@calvinalkan Most likely this functionality won't work with PHPUnit 10, unless we implement error expectations in Codeception\Test\Unit but in that case it will be limited to tests extending Codeception\Test\Unit.

See sebastianbergmann/phpunit@d4b3d9d

Are there other usecase other than in classes extening Unit?

Of the top of my head I cant think of any.

In Browser and cli tests you cant make assertions about errors this way no matter what

@Naktibalda
Copy link
Member Author

Tests extending \PHPUnit\Framework\TestCase directly.

@Naktibalda
Copy link
Member Author

The good news is that expectation methods had been removed in PHPUnit 10, so there will be no expectation for Codeception to support them :)

See sebastianbergmann/phpunit@a2c784c

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

Successfully merging this pull request may close these issues.

2 participants