Пример #1
0
 public function testAddingRoutes()
 {
     $callback = function () {
     };
     $app = new Application();
     $app->get('/get', $callback);
     $app->post('/post', $callback);
     $app->put('/put', $callback);
     $app->delete('/delete', $callback);
     $app->head('/head', $callback);
     $app->options('/options', $callback);
     $app->patch('/patch', $callback);
     $routes = $app['router']->getRoutes();
     $this->assertCount(7, $routes);
     $this->assertInstanceOf(Route::class, $routes[0]);
     $this->assertInstanceOf(Route::class, $routes[1]);
     $this->assertInstanceOf(Route::class, $routes[2]);
     $this->assertInstanceOf(Route::class, $routes[3]);
     $this->assertInstanceOf(Route::class, $routes[4]);
     $this->assertInstanceOf(Route::class, $routes[5]);
     $this->assertInstanceOf(Route::class, $routes[6]);
     $this->assertSame('/get', $routes[0]->getPath());
     $this->assertSame('/post', $routes[1]->getPath());
     $this->assertSame('/put', $routes[2]->getPath());
     $this->assertSame('/delete', $routes[3]->getPath());
     $this->assertSame('/head', $routes[4]->getPath());
     $this->assertSame('/options', $routes[5]->getPath());
     $this->assertSame('/patch', $routes[6]->getPath());
     $this->assertSame('GET', $routes[0]->getMethod());
     $this->assertSame('POST', $routes[1]->getMethod());
     $this->assertSame('PUT', $routes[2]->getMethod());
     $this->assertSame('DELETE', $routes[3]->getMethod());
     $this->assertSame('HEAD', $routes[4]->getMethod());
     $this->assertSame('OPTIONS', $routes[5]->getMethod());
     $this->assertSame('PATCH', $routes[6]->getMethod());
     $this->assertSame($callback, $routes[0]->getCallback());
     $this->assertSame($callback, $routes[1]->getCallback());
     $this->assertSame($callback, $routes[2]->getCallback());
     $this->assertSame($callback, $routes[3]->getCallback());
     $this->assertSame($callback, $routes[4]->getCallback());
     $this->assertSame($callback, $routes[5]->getCallback());
     $this->assertSame($callback, $routes[6]->getCallback());
 }