Update tests to to avoid passing a reveal() return value by reference.
This commit is contained in:
parent
b14641d2f4
commit
4a75f4e3a6
|
|
@ -30,9 +30,12 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase
|
|||
$middleware->dispatch(Argument::cetera())->willReturn();
|
||||
|
||||
$map = new MethodMap(["GET" => $middleware->reveal()]);
|
||||
$map->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$middleware->dispatch($this->request->reveal(), $this->response->reveal())->shouldHaveBeenCalled();
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$map->dispatch($request, $response);
|
||||
|
||||
$middleware->dispatch($request, $response)->shouldHaveBeenCalled();
|
||||
}
|
||||
|
||||
public function testDispatchesGetMiddlewareForHeadByDefault()
|
||||
|
|
@ -43,9 +46,12 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase
|
|||
$middleware->dispatch(Argument::cetera())->willReturn();
|
||||
|
||||
$map = new MethodMap(["GET" => $middleware->reveal()]);
|
||||
$map->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$middleware->dispatch($this->request->reveal(), $this->response->reveal())->shouldHaveBeenCalled();
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$map->dispatch($request, $response);
|
||||
|
||||
$middleware->dispatch($request, $response)->shouldHaveBeenCalled();
|
||||
}
|
||||
|
||||
public function testRegistersMiddlewareForMultipleMethods()
|
||||
|
|
@ -56,13 +62,16 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase
|
|||
$map = new MethodMap();
|
||||
$map->add("GET,POST", $middleware->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
|
||||
$this->request->getMethod()->willReturn("GET");
|
||||
$map->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
$map->dispatch($request, $response);
|
||||
|
||||
$this->request->getMethod()->willReturn("POST");
|
||||
$map->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
$map->dispatch($request, $response);
|
||||
|
||||
$middleware->dispatch($this->request->reveal(), $this->response->reveal())->shouldHaveBeenCalledTimes(2);
|
||||
$middleware->dispatch($request, $response)->shouldHaveBeenCalledTimes(2);
|
||||
}
|
||||
|
||||
public function testSetsStatusTo200ForOptions()
|
||||
|
|
@ -72,7 +81,10 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase
|
|||
$middleware = $this->prophesize("\\WellRESTed\\Routing\\MiddlewareInterface");
|
||||
|
||||
$map = new MethodMap(["GET" => $middleware->reveal()]);
|
||||
$map->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$map->dispatch($request, $response);
|
||||
|
||||
$this->response->withStatus(200)->shouldHaveBeenCalled();
|
||||
}
|
||||
|
|
@ -91,7 +103,9 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase
|
|||
$map->add($method, $middleware->reveal());
|
||||
}
|
||||
|
||||
$map->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$map->dispatch($request, $response);
|
||||
|
||||
$containsAllMethods = function ($headerValue) use ($methodsAllowed) {
|
||||
foreach ($methodsAllowed as $method) {
|
||||
|
|
@ -111,7 +125,10 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase
|
|||
$middleware = $this->prophesize("\\WellRESTed\\Routing\\MiddlewareInterface");
|
||||
|
||||
$map = new MethodMap(["GET" => $middleware->reveal()]);
|
||||
$map->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$map->dispatch($request, $response);
|
||||
|
||||
$this->response->withStatus(405)->shouldHaveBeenCalled();
|
||||
}
|
||||
|
|
@ -130,7 +147,9 @@ class MethodMapTest extends \PHPUnit_Framework_TestCase
|
|||
$map->add($method, $middleware->reveal());
|
||||
}
|
||||
|
||||
$map->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$map->dispatch($request, $response);
|
||||
|
||||
$containsAllMethods = function ($headerValue) use ($methodsAllowed) {
|
||||
foreach ($methodsAllowed as $method) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ class RouteTest extends \PHPUnit_Framework_TestCase
|
|||
$response = $response->withStatus(200);
|
||||
};
|
||||
$route = new StaticRoute("/", $middleware);
|
||||
$route->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$route->dispatch($request, $response);
|
||||
$this->response->withStatus(200)->shouldHaveBeenCalled();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,11 @@ class RouteTableTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$table = new RouteTable();
|
||||
$table->addStaticRoute($route->reveal());
|
||||
$table->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$route->dispatch($this->request->reveal(), $this->response->reveal())->shouldHaveBeenCalled();
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$table->dispatch($request, $response);
|
||||
$route->dispatch($request, $response)->shouldHaveBeenCalled();
|
||||
}
|
||||
|
||||
public function testMatchesPrefixRoute()
|
||||
|
|
@ -42,9 +44,11 @@ class RouteTableTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$table = new RouteTable();
|
||||
$table->addPrefixRoute($route->reveal());
|
||||
$table->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$route->dispatch($this->request->reveal(), $this->response->reveal())->shouldHaveBeenCalled();
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$table->dispatch($request, $response);
|
||||
$route->dispatch($request, $response)->shouldHaveBeenCalled();
|
||||
}
|
||||
|
||||
public function testMatchesBestPrefixRoute()
|
||||
|
|
@ -62,7 +66,10 @@ class RouteTableTest extends \PHPUnit_Framework_TestCase
|
|||
$table = new RouteTable();
|
||||
$table->addPrefixRoute($route1->reveal());
|
||||
$table->addPrefixRoute($route2->reveal());
|
||||
$table->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$table->dispatch($request, $response);
|
||||
|
||||
$route1->dispatch(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
$route2->dispatch(Argument::cetera())->shouldHaveBeenCalled();
|
||||
|
|
@ -83,7 +90,10 @@ class RouteTableTest extends \PHPUnit_Framework_TestCase
|
|||
$table = new RouteTable();
|
||||
$table->addPrefixRoute($route1->reveal());
|
||||
$table->addStaticRoute($route2->reveal());
|
||||
$table->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$table->dispatch($request, $response);
|
||||
|
||||
$route1->dispatch(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
$route2->dispatch(Argument::cetera())->shouldHaveBeenCalled();
|
||||
|
|
@ -103,7 +113,10 @@ class RouteTableTest extends \PHPUnit_Framework_TestCase
|
|||
$table = new RouteTable();
|
||||
$table->addPrefixRoute($route1->reveal());
|
||||
$table->addRoute($route2->reveal());
|
||||
$table->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$table->dispatch($request, $response);
|
||||
|
||||
$route1->dispatch(Argument::cetera())->shouldHaveBeenCalled();
|
||||
$route2->dispatch(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
|
|
@ -128,7 +141,10 @@ class RouteTableTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$table = new RouteTable();
|
||||
$table->addRoute($route);
|
||||
$table->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$table->dispatch($request, $response);
|
||||
|
||||
$this->request->withAttribute("id", "molly")->shouldHaveBeenCalled();
|
||||
}
|
||||
|
|
@ -151,7 +167,10 @@ class RouteTableTest extends \PHPUnit_Framework_TestCase
|
|||
$table->addRoute($route1->reveal());
|
||||
$table->addRoute($route2->reveal());
|
||||
$table->addRoute($route3->reveal());
|
||||
$table->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$table->dispatch($request, $response);
|
||||
|
||||
$route1->dispatch(Argument::cetera())->shouldNotHaveBeenCalled();
|
||||
$route2->dispatch(Argument::cetera())->shouldHaveBeenCalled();
|
||||
|
|
|
|||
|
|
@ -48,7 +48,10 @@ class RouterTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$router = new Router();
|
||||
$router->add("/cats/", $this->middleware->reveal());
|
||||
$router->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$router->dispatch($request, $response);
|
||||
|
||||
$this->middleware->dispatch(Argument::cetera())->shouldHaveBeenCalled();
|
||||
}
|
||||
|
|
@ -63,7 +66,10 @@ class RouterTest extends \PHPUnit_Framework_TestCase
|
|||
$router = new Router();
|
||||
$router->addPreRouteHook($hook->reveal());
|
||||
$router->add("/cats/", $this->middleware->reveal());
|
||||
$router->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$router->dispatch($request, $response);
|
||||
|
||||
$hook->dispatch(Argument::cetera())->shouldHaveBeenCalled();
|
||||
}
|
||||
|
|
@ -78,7 +84,10 @@ class RouterTest extends \PHPUnit_Framework_TestCase
|
|||
$router = new Router();
|
||||
$router->addPostRouteHook($hook->reveal());
|
||||
$router->add("/cats/", $this->middleware->reveal());
|
||||
$router->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$router->dispatch($request, $response);
|
||||
|
||||
$hook->dispatch(Argument::cetera())->shouldHaveBeenCalled();
|
||||
}
|
||||
|
|
@ -90,7 +99,10 @@ class RouterTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$router = new Router();
|
||||
$router->add("/cats/", $this->middleware->reveal());
|
||||
$router->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$router->dispatch($request, $response);
|
||||
|
||||
$this->response->withStatus(404)->shouldHaveBeenCalled();
|
||||
}
|
||||
|
|
@ -105,7 +117,10 @@ class RouterTest extends \PHPUnit_Framework_TestCase
|
|||
$router = new Router();
|
||||
$router->add("/cats/", $this->middleware->reveal());
|
||||
$router->setStatusHandler(403, $statusMiddleware->reveal());
|
||||
$router->dispatch($this->request->reveal(), $this->response->reveal());
|
||||
|
||||
$request = $this->request->reveal();
|
||||
$response = $this->response->reveal();
|
||||
$router->dispatch($request, $response);
|
||||
|
||||
$statusMiddleware->dispatch(Argument::cetera())->shouldHaveBeenCalled();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue