Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bootstrap the Request instance in Lumen 5.5
<?php
namespace Tests;
use Illuminate\Http\Request;
use Laravel\Lumen\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
/**
* Creates the application.
*
* @return \Laravel\Lumen\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$uri = $app->make('config')->get('app.url', 'http://localhost');
$components = parse_url($uri);
$server = $_SERVER;
if (isset($components['path'])) {
$server = array_merge($server, [
'SCRIPT_FILENAME' => $components['path'],
'SCRIPT_NAME' => $components['path'],
]);
}
$app->instance('request', Request::create(
$uri, 'GET', [], [], [], $server
));
return $app;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment