/** * The main method that delegates work to make the route itself. Can accept * a specific RouteCreatorInterface to use for one call to create. If any * required information is missing, it will throw an Exception and stop * progressing through the Routes to be generated. * * @param RouteCreatorInterface $creator * * @throws RouterMethodNotDefinedException * @throws RouteMethodNotDefinedException * @throws RouteUriNotDefinedException * @throws RouteActionNotDefinedException * @throws RouteCreatorNullException */ public function create(RouteCreatorInterface $creator = null) { if (!is_null($creator)) { $this->setCreator($creator); } if (is_null($this->creator)) { throw new RouteCreatorNullException(); } foreach ($this->creator->getRouteInfo() as $r) { list($method, $uri, $action) = $this->parseRoute($r); $this->makeRoute($method, $uri, $action); } }
function it_requires_that_the_router_has_the_requested_method(RouteCreator $creator) { $f = function () { echo 'test'; }; $creator->getRouteInfo()->willReturn(array(array('method' => 'foo', 'uri' => 'test', 'action' => $f))); $this->shouldThrow('Rupertjeff\\DynamicRouting\\Exceptions\\RouterMethodNotDefined')->during('create', array($creator)); }