/** * @covers ::configureDependencyInjection */ public function testClassParameters() { //setup $module = new FastRouteModule(); $dic = new DependencyInjectionContainerMock(); $config = [$module->getModuleKey() => ['routes' => [], 'errorHandlers' => [404 => [MockRouteTarget::class, 'targetMethod']]]]; //act $module->configureDependencyInjection($dic, $config[$module->getModuleKey()], $config); //assert $this->assertEquals([FastRouteConfiguration::class => ['routes' => [], 'errorHandlers' => [404 => [MockRouteTarget::class, 'targetMethod']]]], $dic->getClassParameters()); }
/** * @covers Piccolo\Web\Routing\FastRoute\FastRouteRouter * @covers Piccolo\Web\Routing\FastRoute\FastRouteConfiguration * @covers Piccolo\Web\Routing\FastRoute\FastRouteModule */ public function testMethodNotAllowed() { //setup $module = new FastRouteModule(); $config = [$module->getModuleKey() => ['routes' => [['GET', '/', MockRouteTarget::class, 'targetMethod']], 'errorHandlers' => [404 => [MockRouteTarget::class, 'notFoundMethod'], 405 => [MockRouteTarget::class, 'methodNotAllowedMethod'], 500 => [MockRouteTarget::class, 'serverErrorMethod']]]]; $dic = new AurynDependencyInjectionContainer(); $module->configureDependencyInjection($dic, $config[$module->getModuleKey()], $config); $request = new ServerRequest('POST', '/'); //act /** * @var Router $router */ $router = $dic->make(Router::class); $result = $router->route($request); //assert $this->assertEquals(MockRouteTarget::class, $result->getClass()); $this->assertEquals('methodNotAllowedMethod', $result->getMethod()); }