예제 #1
0
 public function testGetPathFor()
 {
     // Test data
     $test_path = '/test';
     $test_name = 'Test Route Thing';
     $route = new Route($this->getTestCallable());
     $route->setPath($test_path);
     $route->setName($test_name);
     $this->klein_app->getRoutes()->addRoute($route);
     // Make sure it fails if not prepared
     try {
         $this->klein_app->getPathFor($test_name);
     } catch (Exception $e) {
         $this->assertTrue($e instanceof OutOfBoundsException);
     }
     $this->klein_app->getRoutes()->prepareNamed();
     $returned_path = $this->klein_app->getPathFor($test_name);
     $this->assertNotEmpty($returned_path);
     $this->assertSame($test_path, $returned_path);
 }
예제 #2
0
 public function testNameGetSet()
 {
     // Test data
     $test_callable = $this->getTestCallable();
     $test_name = 'trevor';
     // Empty constructor
     $route = new Route($test_callable);
     $this->assertNull($route->getName());
     // Set in constructor
     $route = new Route($test_callable, null, null, null, $test_name);
     $this->assertSame($test_name, $route->getName());
     // Set in method
     $route = new Route($test_callable);
     $route->setName($test_name);
     $this->assertSame($test_name, $route->getName());
 }