Skip to content
This repository has been archived by the owner on Sep 19, 2018. It is now read-only.

Commit

Permalink
Update testcases based on Laravel 5.1 changes.
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed May 13, 2015
1 parent 224e94e commit c34ca88
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
35 changes: 26 additions & 9 deletions tests/DispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ public function testCallMethodUsingGetVerb()

$app->shouldReceive('make')->with('AppController')->once()->andReturn($useApp)
->shouldReceive('make')->with('FooController')->once()->andReturn($useFoo)
->shouldReceive('make')->times(3)->with('FoobarController')->andReturn($useFoobar);
->shouldReceive('make')->times(3)->with('FoobarController')->andReturn($useFoobar)
->shouldReceive('bound')->with('middleware.disable')->andReturn(false);
$request->shouldReceive('getMethod')->times(6)->andReturn('GET');
$router->shouldReceive('getMiddleware')->times(5)->andReturn([]);
$router->shouldReceive('prepareResponse')->times(5)->with($request, m::type('String'))
->andReturnUsing(function($request, $response) {
return $response;
});

$driver = new Router('app', [
'name' => 'app',
Expand Down Expand Up @@ -100,9 +104,13 @@ public function testCallMethodUsingPostVerb()
$request = $this->request;
$useFoobar = new FoobarController();

$app->shouldReceive('make')->once()->with('FoobarController')->andReturn($useFoobar);
$app->shouldReceive('make')->once()->with('FoobarController')->andReturn($useFoobar)
->shouldReceive('bound')->with('middleware.disable')->andReturn(false);
$request->shouldReceive('getMethod')->once()->andReturn('POST');
$router->shouldReceive('getMiddleware')->once()->andReturn([]);
$router->shouldReceive('prepareResponse')->once()->with($request, m::type('String'))
->andReturnUsing(function($request, $response) {
return $response;
});

$driver = new Router('app', [
'name' => 'app',
Expand Down Expand Up @@ -130,9 +138,13 @@ public function testCallMethodUsingPutVerb()
$request = $this->request;
$useFoobar = new FoobarController();

$app->shouldReceive('make')->once()->with('FoobarController')->andReturn($useFoobar);
$app->shouldReceive('make')->once()->with('FoobarController')->andReturn($useFoobar)
->shouldReceive('bound')->with('middleware.disable')->andReturn(false);
$request->shouldReceive('getMethod')->once()->andReturn('PUT');
$router->shouldReceive('getMiddleware')->once()->andReturn([]);
$router->shouldReceive('prepareResponse')->once()->with($request, m::type('String'))
->andReturnUsing(function($request, $response) {
return $response;
});

$driver = new Router('app', [
'name' => 'app',
Expand Down Expand Up @@ -160,9 +172,13 @@ public function testCallMethodUsingDeleteVerb()
$request = $this->request;
$useFoobar = new FoobarController();

$app->shouldReceive('make')->once()->with('FoobarController')->andReturn($useFoobar);
$app->shouldReceive('make')->once()->with('FoobarController')->andReturn($useFoobar)
->shouldReceive('bound')->with('middleware.disable')->andReturn(false);
$request->shouldReceive('getMethod')->once()->andReturn('DELETE');
$router->shouldReceive('getMiddleware')->once()->andReturn([]);
$router->shouldReceive('prepareResponse')->once()->with($request, m::type('String'))
->andReturnUsing(function($request, $response) {
return $response;
});

$driver = new Router('app', [
'name' => 'app',
Expand All @@ -185,9 +201,10 @@ public function testCallMethodUsingDeleteVerb()
*/
public function testCallMethodThrowsException()
{
$app = $this->app;
$request = $this->request;
$router = $this->router;
$stub = new Dispatcher($this->app, $router, $request);
$stub = new Dispatcher($app, $router, $request);

$request->shouldReceive('getMethod')->once()->andReturn('GET');

Expand Down
3 changes: 2 additions & 1 deletion tests/Routing/ControllerDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function testRunMethodThrowsException()

$router->shouldReceive('getMiddleware')->once()->andReturn([]);

$container->shouldReceive('make')->once()->with('FooController')->andReturn($useFoo);
$container->shouldReceive('make')->once()->with('FooController')->andReturn($useFoo)
->shouldReceive('bound')->once()->with('middleware.disable')->andReturn(false);

$stub = new ControllerDispatcher($router, $container);

Expand Down

0 comments on commit c34ca88

Please sign in to comment.