Example #1
0
 public function testMethods()
 {
     $router = new Router();
     $this->assertFalse($router->has("home"));
     $this->assertNull($router->get("home"));
     $this->assertSame(0, $router->count());
     // add one
     $this->assertInstanceOf("SugiPHP\\Routing\\Router", $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\\Router", $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\\Router", $router->delete("home"));
     $this->assertFalse($router->has("home"));
     $this->assertNull($router->get("home"));
     $this->assertSame(0, $router->count());
 }