Closed kanidjar closed 5 years ago
The error only occurs when running tests.
Can you provide some code which reproduces this? Perhaps the test itself?
Sure!
Routes
<?php
use Illuminate\Http\Request;
$router->get('/{id}', function(Request $request) {
return $request->id;
});
Test :
<?php
use Laravel\Lumen\Testing\DatabaseMigrations;
use Laravel\Lumen\Testing\DatabaseTransactions;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testExample()
{
$this->get('/1');
dd($this->response);
}
}
Throws:
+exception: Symfony\Component\Debug\Exception\FatalThrowableError {#52
-originalClassName: "Error"
#message: "Call to a member function parameter() on array"
#code: 0
#file: "./vendor/illuminate/http/Request.php"
#line: 531
#severity: E_ERROR
trace: {
./vendor/illuminate/http/Request.php:531 { …}
./vendor/illuminate/http/Request.php:694 { …}
./vendor/illuminate/support/helpers.php:1138 { …}
./vendor/illuminate/support/Arr.php:293 { …}
./vendor/illuminate/http/Request.php:695 { …}
./routes/web.php:17 {
› $router->get('/{id}', function(Request $request) {
› return $request->id;
› });
arguments: {
$key: "id"
}
}
TestCase->{closure}() {}
./vendor/illuminate/container/BoundMethod.php:29 { …}
./vendor/illuminate/container/BoundMethod.php:75 { …}
./vendor/illuminate/container/BoundMethod.php:31 { …}
./vendor/illuminate/container/Container.php:572 { …}
./vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:291 { …}
./vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:265 { …}
./vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:235 { …}
./vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:169 { …}
./vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:418 { …}
./vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:171 { …}
./vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php:91 { …}
./vendor/laravel/lumen-framework/src/Testing/Concerns/MakesHttpRequests.php:341 { …}
./vendor/laravel/lumen-framework/src/Testing/Concerns/MakesHttpRequests.php:63 { …}
./tests/ExampleTest.php:15 { …}
./vendor/phpunit/phpunit/src/Framework/TestCase.php:1153 { …}
./vendor/phpunit/phpunit/src/Framework/TestCase.php:842 { …}
./vendor/phpunit/phpunit/src/Framework/TestResult.php:687 { …}
./vendor/phpunit/phpunit/src/Framework/TestCase.php:796 { …}
./vendor/phpunit/phpunit/src/Framework/TestSuite.php:746 { …}
./vendor/phpunit/phpunit/src/Framework/TestSuite.php:746 { …}
./vendor/phpunit/phpunit/src/TextUI/TestRunner.php:641 { …}
./vendor/phpunit/phpunit/src/TextUI/Command.php:206 { …}
./vendor/phpunit/phpunit/src/TextUI/Command.php:162 { …}
./vendor/phpunit/phpunit/phpunit:61 { …}
}
The route is working when the app is served by the PHP embedded server.
I can confirm that this is a bug. I've sent in a fix for this.
Great! Thanks for your reactivity on this 👍
Description:
On test mode (phpunit), an exception occurs when calling :
See https://github.com/laravel/lumen-framework/issues/685#issuecomment-443393222