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
[PhpUnitBridge] Remove @expectedException annotation #32875
[PhpUnitBridge] Remove @expectedException annotation #32875
Conversation
ae544cc
to
62d224d
Compare
62d224d
to
a22a9c4
Compare
*/ | ||
public function testLegacyLintCommand() | ||
{ | ||
$this->expectException('RuntimeException'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::class
please. Also it seems you added the expectation always at the beginning of the function. this is mostly not correct like here. the exception is expected when calling a certain method like execute
. This was the main reason why the annotation has been removed in phpunit. this can lead to passing tests that are not meant to pass like exceptions triggered by something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is the raw result of an automate script that moves annotations to calls.
I'm fully agree with you on both points.
- I'll create a dedicated PR to add
::class
on allexpectException
(the ones introduce here + the rest of the code base) - moving declaration of
expectException
to the right place cannot be automated and is too much effort (1295 occurences here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(FCQN + in place "expect" should and can be done separately)
Thank you @jderusse. |
…erusse) This PR was squashed before being merged into the 3.4 branch (closes #32875). Discussion ---------- [PhpUnitBridge] Remove @ExpectedException annotation | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #32844 | License | MIT | Doc PR | NA this PR replaces the deprecated annotation `@expectedException` by calls to the method `expectException`. To automate the process, I used rector/rector: ``` ./vendor/bin/rector process src/Symfony --set phpunit60 -a .phpunit/phpunit-6.5/vendor/autoload.php ``` Which also replace `PHPUnit_Framework_Error_X` by `\PHPUnit\Framework\Error\X` Commits ------- a22a9c4 Fix tests 3a626e8 Fix deprecated phpunit annotation
…newest PHPUnit features (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [PhpUnitBridge] make the bridge act as a polyfill for newest PHPUnit features | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - It's been quite a tunnel these days with @jderusse but here we are: the phpunit-bridge is now a fully working polyfill for newest PHPUnit features. All related PRs have been merged as "minor" but they are now ready for prime time, hence this PR that I'd like to be merged as "feature", to make it part of the changelog of Symfony 4.4. As of version 4.4, the `simple-phpunit` script will run an augmented version of PHPUnit, that will provide the newest assertions of PHPUnit 8 even if you happen to be running PHPUnit 4.8+ (because you still need to test on PHP 5.5, as Symfony does.) The bridge currently provides polyfills for the methods that are needed to make our tests pass on PHP 7.4 with no deprecations: - #32878 #32907 `assertString(Not)ContainsString(IgnoringCase)`, `assertEqualsWithDelta` and `assert(Not)ContainsEquals` - #32875 `expectException*`, which replace `@expectedException*` annotations - #32846 `assertIs*`, which replace `assertInternalType` - #32865 `create(Partial)Mock` - #32931 `assert(File|Directory)(Not)(Exists|IsReadable|IsWritable)` More polyfills might be added if you need them. PRs welcome as usual. As of #32882, when the `SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT` is set to `1`, `simple-phpunit` will also [patch](https://github.com/symfony/symfony/blob/884669b83b131df8c3c41ad6517abe8cff7903b0/src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php#L149) the source of PHPUnit 8 to remove the `void` return-type on `setUp*`/`tearDown*`. This is required when the same codebase must be tested against PHP 5.5 up to 7.4+ (as does our branch 3.4). For codebases that don't want or can't run their tests with `simple-phpunit` but want to run their PHP 5.5 tests with PHPUnit 8, the bridge provides a new `SetUpTearDownTrait` that allows a [smooth transition](https://github.com/php-cache/integration-tests/blob/c59a4d2dec1e462e5f5646e5fe102f403d6b8903/src/CachePoolTest.php#L21) to it. Along the path, we also created a new tool for our CI: it's now possible to submit a new polyfill on the current feature-branch (4.4 these days) and test it with a PR on another branch. See #32887 for the patch. All these new features have been added to achieve PHP 7.4 support on branch 3.4. There are still many deprecations that need to be fixed, all tracked in #32844. It should be a pretty nice list of "good first issues". Thank you @luispabon, @tweichart, @Alexander1000 BTW. A big specific thank you to @jderusse for the help! Let's rock PHP 7.4, can't wait for your PRs, see you on #32844 :) Commits ------- 271211b [PhpUnitBridge] make the bridge act as a polyfill for newest PHPUnit features
this PR replaces the deprecated annotation
@expectedException
by calls to the methodexpectException
.To automate the process, I used rector/rector:
Which also replace
PHPUnit_Framework_Error_X
by\PHPUnit\Framework\Error\X