public function testDefaults() { $route = new Route("/"); $route->setDefaults(array("constructor" => "main")); $this->assertEquals(array("constructor" => "main"), $route->getDefaults()); $route->setDefaults(array("constructor" => "main", "action" => "index")); $this->assertEquals(array("constructor" => "main", "action" => "index"), $route->getDefaults()); $route = new Route("/", array("constructor" => "main")); $this->assertEquals(array("constructor" => "main"), $route->getDefaults()); }
public function testHostVariablesWithRequisites() { $route = new Route("/"); $route->setHost("{lang}.example.com"); $route->setRequisites(array("lang" => "en|bg")); // ok $this->assertTrue($route->match(Request::custom("http://en.example.com/"))); $this->assertTrue($route->match(Request::custom("http://bg.example.com/"))); // fail $this->assertFalse($route->match(Request::custom("http://example.com/"))); $this->assertFalse($route->match(Request::custom("http://.example.com/"))); $this->assertFalse($route->match(Request::custom("http://ru.example.com/"))); $this->assertFalse($route->match(Request::custom("http://ru.example.com/"))); $this->assertFalse($route->match(Request::custom("http://www.en.example.com/"))); $this->assertFalse($route->match(Request::custom("http://english.example.com/"))); // with default value $route->setDefaults(array("lang" => "en")); // ok $this->assertTrue($route->match(Request::custom("http://example.com/"))); // fails $this->assertFalse($route->match(Request::custom("http://ru.example.com/"))); }