public function testRouteParameterWithEmptyRoute()
 {
     $router = Mockery::mock('\\Illuminate\\Routing\\Router');
     $router->shouldReceive('current')->andReturn(null);
     $active = new HieuLe\Active\Active($router);
     $this->assertSame('', $active->routeParam('foo', []));
 }
Example #2
0
 public function testRoutePatternMethod()
 {
     $router = Mockery::mock('\\Illuminate\\Routing\\Router');
     $router->shouldReceive('currentRouteName')->times(4)->andReturn('prefix.foo.create');
     $active = new HieuLe\Active\Active($router);
     $this->assertEquals('active', $active->routePattern('*.foo.*'));
     $this->assertEquals('', $active->routePattern('*.foo'));
     $this->assertEquals('selected', $active->routePattern('*.foo.*', 'selected'));
     $this->assertEquals('active', $active->routePattern('*.create'));
 }
Example #3
0
 public function testQueryMethod()
 {
     $request = Mockery::mock('\\Illuminate\\Http\\Request');
     $request->shouldReceive('query')->times(6)->andReturnUsing(function ($arg) {
         switch ($arg) {
             case 'foo':
                 return 'bar';
             case 'lorems':
                 return ['baz', 'ipsum'];
         }
         return null;
     });
     $router = Mockery::mock('\\Illuminate\\Routing\\Router');
     $router->shouldReceive('getCurrentRequest')->times(6)->andReturn($request);
     $active = new \HieuLe\Active\Active($router);
     $this->assertEquals('active', $active->query('foo', 'bar'));
     $this->assertEquals('', $active->query('foo', 'barr'));
     $this->assertEquals('normal', $active->query('foo', 'barr', 'active', 'normal'));
     $this->assertEquals('selected', $active->query('lorems', 'baz', 'selected'));
     $this->assertEquals('', $active->query('lorems', 'bazz', 'selected'));
     $this->assertEquals('normal', $active->query('lorems', 'bazz', 'selected', 'normal'));
 }