isActiveRoute() public method

Any section of the route name can be replaced with a * wildcard. Example: user.*
public isActiveRoute ( string $routeName, string $output = "active" ) : boolean
$routeName string
$output string
return boolean
Example #1
0
 /** @test */
 public function it_detects_active_route_by_name()
 {
     $router = m::mock(\Illuminate\Routing\Router::class);
     $router->shouldReceive('currentRouteName')->times(8)->andReturn('users.index');
     $url = m::mock(\Illuminate\Routing\UrlGenerator::class);
     $ekko = new Ekko($router, $url);
     $this->assertEquals("active", $ekko->isActiveRoute('users.index'));
     $this->assertEquals("hello", $ekko->isActiveRoute('users.index', 'hello'));
     $this->assertEquals(null, $ekko->isActiveRoute('clients.index'));
     $this->assertEquals(null, $ekko->isActiveRoute('clients.index', 'hello'));
     // Wildcard support
     $this->assertEquals("active", $ekko->isActiveRoute('users.*'));
     $this->assertEquals("hello", $ekko->isActiveRoute('users.*', 'hello'));
     $this->assertEquals(null, $ekko->isActiveRoute('clients.*'));
     $this->assertEquals(null, $ekko->isActiveRoute('clients.*', 'hello'));
 }