In order to support PHPUnit 8, the setUp and tearDown methods in Laravel's TestCase need to be set to return void
e.g.
tearDown() : void
ping @GrahamCampbell - your the expert at this type of stuff...
It turns out, it isn't as simple as making those changes. Many tests return warnings related to Laravel's usage of assertContains() in TestResponse.php:
Using assertContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringContainsString() or assertStringContainsStringIgnoringCase() instead.
Using assertNotContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringNotContainsString() or assertStringNotContainsStringIgnoringCase() instead.
Also the assertJson methods use assertArraySubset:
assertArraySubset() is deprecated and will be removed in PHPUnit 9.
There are probably other issues too, but it looks like for now, Laravel users will need to stick with PHPUnit 7.*
Ping @driesvints
The release statement mentions the deprecation changes quite well: https://phpunit.de/announcements/phpunit-8.html
Indeed it does, but it鈥檒l require changes to Laravel鈥檚 TestResponse, and maybe other areas for the two to be compatible.
At a first glance, I see:
I am curious how this will be handled moving forward. Ideally 5.8 would support PHPUnit 8, leaving <=5.7 to use PHPUnit 7?
Seems a bit of a catch 22, see also https://github.com/orchestral/testbench/issues/238
Hi everyone,
I know @taylorotwell and @driesvints are aware of this general issue with PHPUnit 8 - so they will be working on a plan/solution behind the scenes.
We'll leave the ticket open so people are aware.
Heya. We're indeed aware and I'm going to try to have a look at this this week.
I've made 2 PR for this: https://github.com/laravel/framework/pull/27431 and https://github.com/laravel/framework/pull/27432, but they both require an upgrade to PHP 7.2
@lucasmichot I'll probably look into this today
Sent in a PR. Tests are failing atm until testbench has been updated: https://github.com/laravel/framework/pull/27441
@driesvints just merge phpunit8 to 3.8 branch. You can revert changes to composer.json now.
Which version of phpunit we should use ?
Which version of phpunit we should use ?
I use php version 7.2 and phpunit version 8.0, I replaced in my tests 'assertContains' by 'assertStringContainsString' and it works for me!
Closing this as PHPUnit 8 support will be available once Laravel 5.8 is released.
Most helpful comment
I've made 2 PR for this: https://github.com/laravel/framework/pull/27431 and https://github.com/laravel/framework/pull/27432, but they both require an upgrade to PHP 7.2