Completed
Push — master ( 34e334...39d639 )
by Oleg
04:32
created

MenuTest::testFacade()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Malezha\Menu\Tests;
3
4
use Malezha\Menu\Contracts\Builder;
5
use Malezha\Menu\Contracts\Menu;
6
7
/**
8
 * Class MenuTest
9
 * @package Malezha\Menu\Tests
10
 */
11
class MenuTest extends TestCase
12
{
13
    /**
14
     * @return Menu
15
     */
16
    protected function menuFactory()
17
    {
18
        /** @var Menu $menu */
19
        $menu = $this->app->make(Menu::class, ['container' => $this->app]);
20
        $menu->make('test', function(Builder $builder) {
21
            $builder->add('one', 'One', '/one');
22
        });
23
        
24
        return $menu;
25
    }
26
    
27
    public function testFacade()
28
    {
29
        $this->assertInstanceOf(Menu::class, \Menu::getFacadeRoot());
30
    }
31
    
32
    public function testGet()
33
    {
34
        $menu = $this->menuFactory();
35
        $builder = $menu->get('test');
36
        $this->assertInstanceOf(Builder::class, $builder);
37
    }
38
39
    /**
40
     * @expectedException \RuntimeException
41
     */
42
    public function testGetException()
43
    {
44
        $menu = \Menu::get('test');
0 ignored issues
show
Unused Code introduced by
$menu is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
45
    }
46
    
47
    public function testHas()
48
    {
49
        $menu = $this->menuFactory();
50
        $this->assertFalse($menu->has('another'));
51
        $this->assertTrue($menu->has('test'));
52
    }
53
    
54
    public function testForget()
55
    {
56
        $menu = $this->menuFactory();
57
        $menu->forget('test');
58
        $this->assertAttributeEquals([], 'menuList', $menu);
59
    }
60
    
61
    public function testRender()
62
    {
63
        $menu = $this->menuFactory();
64
        $file = file_get_contents(__DIR__ . '/stub/facade_render.html');
65
        $this->assertEquals($file, $menu->render('test'));
66
    }
67
}