| @@ 146-159 (lines=14) @@ | ||
| 143 | /** |
|
| 144 | * @test |
|
| 145 | */ |
|
| 146 | public function shouldCorrectlyReturnMethodNotAllowed() |
|
| 147 | { |
|
| 148 | $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
| 149 | $this->request = ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); |
|
| 150 | $router = new Selami\Router( |
|
| 151 | $this->routes, |
|
| 152 | $this->config['default_return_type'], |
|
| 153 | $this->request->getMethod(), |
|
| 154 | $this->request->getUri()->getPath(), |
|
| 155 | $this->config['folder'] |
|
| 156 | ); |
|
| 157 | $routeInfo = $router->getRoute(); |
|
| 158 | $this->assertEquals('405', $routeInfo['route']['status'], "Router didn't correctly return Method Not Allowed"); |
|
| 159 | } |
|
| 160 | ||
| 161 | /** |
|
| 162 | * @test |
|
| @@ 164-178 (lines=15) @@ | ||
| 161 | /** |
|
| 162 | * @test |
|
| 163 | */ |
|
| 164 | public function shouldCorrectlyReturnNotFound() |
|
| 165 | { |
|
| 166 | $_SERVER['REQUEST_URI'] = '/notexists'; |
|
| 167 | $_SERVER['REQUEST_METHOD'] = 'POST'; |
|
| 168 | $this->request = ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); |
|
| 169 | $router = new Selami\Router( |
|
| 170 | $this->routes, |
|
| 171 | $this->config['default_return_type'], |
|
| 172 | $this->request->getMethod(), |
|
| 173 | $this->request->getUri()->getPath(), |
|
| 174 | $this->config['folder'] |
|
| 175 | ); |
|
| 176 | $routeInfo = $router->getRoute(); |
|
| 177 | $this->assertEquals('404', $routeInfo['route']['status'], "Router didn't correctly returnNot FOund"); |
|
| 178 | } |
|
| 179 | } |
|
| 180 | ||