public function testMethods() { $router = new RouteCollection(); $this->assertFalse($router->has("home")); $this->assertNull($router->get("home")); $this->assertSame(0, $router->count()); // add one $this->assertInstanceOf("SugiPHP\\Routing\\RouteCollection", $router->add("home", new Route("/"))); $this->assertSame(1, $router->count()); $this->assertTrue($router->has("home")); $this->assertInstanceOf("SugiPHP\\Routing\\Route", $router->get("home")); // change it $this->assertInstanceOf("SugiPHP\\Routing\\RouteCollection", $router->set("home", new Route("/foo"))); $this->assertSame(1, $router->count()); $this->assertTrue($router->has("home")); $this->assertInstanceOf("SugiPHP\\Routing\\Route", $router->get("home")); // remove it $this->assertInstanceOf("SugiPHP\\Routing\\RouteCollection", $router->delete("home")); $this->assertFalse($router->has("home")); $this->assertNull($router->get("home")); $this->assertSame(0, $router->count()); }
public function testDelete() { $_SERVER['REQUEST_METHOD'] = 'DELETE'; $routes = new RouteCollection(); $expected = ['here' => '\\there']; $routes->delete('here', 'there'); $this->assertEquals($expected, $routes->getRoutes()); }