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->routes()->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->routes()->prepareNamed(); $returned_path = $this->klein_app->getPathFor($test_name); $this->assertNotEmpty($returned_path); $this->assertSame($test_path, $returned_path); }
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()); }