【发布时间】:2017-08-31 18:05:18
【问题描述】:
在我们之前的应用程序中,使用 Laravel 5.3,将 processIsolation 设置为 false 可以加快我们的测试速度而不会导致任何错误:
phpunit.xml:
<phpunit backupGlobals="false"
...
processIsolation="false"
stopOnFailure="false">
在我们当前的项目中,在 laravel 5.4 中,将 processIsolation 设置为 false 会导致我们所有的功能测试失败(尽管它们确实更快)(为简洁起见删除了一些):
5) Tests\Feature\CallsToActionApiControllerTest::testUsers
Symfony\Component\HttpKernel\Exception\NotFoundHttpException:
/johnny/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:161
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Router.php:533
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Router.php:512
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Router.php:498
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:174
/johnny/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30
/johnny/vendor/barryvdh/laravel-cors/src/HandleCors.php:34
/johnny/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:148
...
/johnny/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:102
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:149
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:116
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:234
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:206
/johnny/tests/Functional/CallsToAction/CallsToActionApiControllerTest.php:142
...
7) Tests\Feature\EmailEndpointControllerTest::testCaptureEventsWithBlankRequest
Expected status code 200 but received 404.
Failed asserting that false is true.
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/johnny/tests/Functional/Email/EmailActionApiControllerTest.php:88
8) Tests\Feature\EmailEndpointControllerTest::testUnsubscribe
Expected status code 200 but received 404.
Failed asserting that false is true.
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/johnny/tests/Functional/Email/EmailActionApiControllerTest.php:96
9) Tests\Feature\EmailEndpointControllerTest::testUnsubscribeWithAlreadyUnsubscribedEmail
Expected status code 200 but received 404.
Failed asserting that false is true.
/johnny/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/johnny/tests/Functional/Email/EmailActionApiControllerTest.php:108
ERRORS!
Tests: 72, Assertions: 79, Errors: 21, Failures: 9.
Script ./vendor/bin/phpunit handling the test event returned with error code 2
都是404错误,或者NotFoundHttpException错误。
我们早期的工作项目是 laravel 5.3 和 phpunit 5.5;我们当前损坏的项目是 laravel 5.4 和 phpunit 5.7。我注意到两个 laravel 之间的一个变化是 app.php 中的应用程序 URL 更改为
'url' => 'http://localhost'
到
'url' => env('APP_URL', 'http://localhost'),
但改回来并没有做任何事情。请帮忙——我们的测试需要 10 分钟而不是 10 秒。
【问题讨论】:
标签: php phpunit laravel-5.4