diff --git a/composer.json b/composer.json index 33056705..317b3fcb 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,8 @@ }, "autoload": { "psr-4": { - "Laravel\\Lumen\\": "src/" + "Laravel\\Lumen\\": "src/", + "Laravel\\Lumen\\Tests\\": "tests/" }, "classmap": [ "src/Foundation" diff --git a/tests/FullApplicationTest.php b/tests/FullApplicationTest.php index 6d3bb2d1..cd3e27a7 100644 --- a/tests/FullApplicationTest.php +++ b/tests/FullApplicationTest.php @@ -1,10 +1,12 @@ middleware(['LumenTestMiddleware']); + $app->middleware(['Laravel\Lumen\Tests\LumenTestMiddleware']); $app->get('/', function () { return response('Hello World'); @@ -48,13 +50,13 @@ public function testRouteMiddleware() { $app = new Application; - $app->routeMiddleware(['foo' => 'LumenTestMiddleware']); + $app->routeMiddleware(['foo' => 'Laravel\Lumen\Tests\LumenTestMiddleware']); $app->get('/', function () { return response('Hello World'); }); - $app->get('/foo', ['middleware' => 'foo', function() { + $app->get('/foo', ['middleware' => 'foo', function () { return response('Hello World'); }]); @@ -72,15 +74,15 @@ public function testGroupRouteMiddleware() { $app = new Application; - $app->routeMiddleware(['foo' => 'LumenTestMiddleware']); + $app->routeMiddleware(['foo' => 'Laravel\Lumen\Tests\LumenTestMiddleware']); - $app->group(['middleware' => 'foo'], function($app) { + $app->group(['middleware' => 'foo'], function ($app) { $app->get('/', function () { return response('Hello World'); }); }); - $app->get('/foo', function() { + $app->get('/foo', function () { return response('Hello World'); }); @@ -97,7 +99,10 @@ public function testGroupRouteMiddleware() public function testNotFoundResponse() { $app = new Application; - $app->instance('Illuminate\Contracts\Debug\ExceptionHandler', $mock = m::mock('Laravel\Lumen\Exceptions\Handler[report]')); + $app->instance( + 'Illuminate\Contracts\Debug\ExceptionHandler', + $mock = m::mock('Laravel\Lumen\Exceptions\Handler[report]') + ); $mock->shouldIgnoreMissing(); $app->get('/', function () { @@ -113,7 +118,10 @@ public function testNotFoundResponse() public function testMethodNotAllowedResponse() { $app = new Application; - $app->instance('Illuminate\Contracts\Debug\ExceptionHandler', $mock = m::mock('Laravel\Lumen\Exceptions\Handler[report]')); + $app->instance( + 'Illuminate\Contracts\Debug\ExceptionHandler', + $mock = m::mock('Laravel\Lumen\Exceptions\Handler[report]') + ); $mock->shouldIgnoreMissing(); $app->post('/', function () { @@ -130,12 +138,12 @@ public function testControllerResponse() { $app = new Application; - $app->get('/', 'LumenTestController@action'); + $app->get('/', 'Laravel\Lumen\Tests\LumenTestController@action'); $response = $app->handle(Request::create('/', 'GET')); $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('LumenTestController', $response->getContent()); + $this->assertEquals('Laravel\Lumen\Tests\LumenTestController', $response->getContent()); } @@ -143,16 +151,14 @@ public function testNamespacedControllerResponse() { $app = new Application; - require_once __DIR__.'/fixtures/TestController.php'; - - $app->group(['namespace' => 'Lumen\Tests'], function($app) { + $app->group(['namespace' => 'Laravel\Lumen\Tests'], function ($app) { $app->get('/', 'TestController@action'); }); $response = $app->handle(Request::create('/', 'GET')); $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('Lumen\Tests\TestController', $response->getContent()); + $this->assertEquals('Laravel\Lumen\Tests\TestController', $response->getContent()); } @@ -162,11 +168,11 @@ public function testGeneratingUrls() $app->instance('request', Request::create('http://lumen.com', 'GET')); unset($app->availableBindings['request']); - $app->get('/foo-bar', ['as' => 'foo', function() { + $app->get('/foo-bar', ['as' => 'foo', function () { // }]); - $app->get('/foo-bar/{baz}/{boom}', ['as' => 'bar', function() { + $app->get('/foo-bar/{baz}/{boom}', ['as' => 'bar', function () { // }]); @@ -182,15 +188,15 @@ public function testGeneratingUrlsForRegexParameters() $app->instance('request', Request::create('http://lumen.com', 'GET')); unset($app->availableBindings['request']); - $app->get('/foo-bar', ['as' => 'foo', function() { + $app->get('/foo-bar', ['as' => 'foo', function () { // }]); - $app->get('/foo-bar/{baz:[0-9]+}/{boom}', ['as' => 'bar', function() { + $app->get('/foo-bar/{baz:[0-9]+}/{boom}', ['as' => 'bar', function () { // }]); - $app->get('/foo-bar/{baz:[0-9]+}/{boom:[0-9]+}', ['as' => 'baz', function() { + $app->get('/foo-bar/{baz:[0-9]+}/{boom:[0-9]+}', ['as' => 'baz', function () { // }]); @@ -200,21 +206,3 @@ public function testGeneratingUrlsForRegexParameters() $this->assertEquals('http://lumen.com/foo-bar/1/2', route('baz', ['baz' => 1, 'boom' => 2])); } } - -class LumenTestService {} - -class LumenTestMiddleware { - public function handle($request, $next) { - return response('Middleware'); - } -} - -class LumenTestController { - public $service; - public function __construct(LumenTestService $service) { - $this->service = $service; - } - public function action() { - return response(__CLASS__); - } -} diff --git a/tests/LumenTestController.php b/tests/LumenTestController.php new file mode 100644 index 00000000..41a2cb03 --- /dev/null +++ b/tests/LumenTestController.php @@ -0,0 +1,15 @@ +service = $service; + } + public function action() + { + return response(__CLASS__); + } +} diff --git a/tests/LumenTestMiddleware.php b/tests/LumenTestMiddleware.php new file mode 100644 index 00000000..c00fb3f3 --- /dev/null +++ b/tests/LumenTestMiddleware.php @@ -0,0 +1,10 @@ +