Skip to content

Commit

Permalink
Merge pull request #10 from christyjacob4/feat-add-set-route-method
Browse files Browse the repository at this point in the history
feat: added setRoute method
  • Loading branch information
eldadfux authored Mar 4, 2021
2 parents 3c11f01 + 287ce11 commit bfdb236
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,29 @@ public static function getRoutes(): array
return self::$routes;
}

/**
* Get the current route
*
* @return null|Route
*/
public function getRoute(): ?Route
{
return $this->route ?? null;
}

/**
* Set the current route
*
* @param Route $route
*
* @return self
*/
public function setRoute(Route $route): self
{
$this->route = $route;
return $this;
}

/**
* Add Route
*
Expand Down
10 changes: 10 additions & 0 deletions tests/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,16 @@ public function testMiddleWare() {
$this->assertEquals('x-def', $result);
}

public function testSetRoute() {
App::reset();

$route = new Route('GET', '/path');

$this->assertEquals($this->app->getRoute(), null);
$this->app->setRoute($route);
$this->assertEquals($this->app->getRoute(), $route);
}

public function tearDown():void
{
$this->app = null;
Expand Down

0 comments on commit bfdb236

Please sign in to comment.