public function testPathGetSet() { // Test data $test_callable = $this->getTestCallable(); $test_path = '/this-is-a-path'; // Empty constructor $route = new Route($test_callable); $this->assertNotNull($route->getPath()); $this->assertInternalType('string', $route->getPath()); // Set in constructor $route = new Route($test_callable, $test_path); $this->assertSame($test_path, $route->getPath()); // Set in method $route = new Route($test_callable); $route->setPath($test_path); $this->assertSame($test_path, $route->getPath()); }
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); }