it_destroys_menu_item()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 17
rs 9.4286
cc 1
eloc 12
nc 1
nop 0
1
<?php namespace Modules\Menu\Tests;
2
3
class EloquentMenuItemRepositoryTest extends BaseMenuTest
4
{
5
    public function setUp()
6
    {
7
        parent::setUp();
8
    }
9
10
    /**
11
     * New menu item should be created
12
     * @test
13
     */
14
    public function it_should_create_menu_item_as_root()
15
    {
16
        $menu = $this->createMenu('second', 'Second Menu');
17
18
        $data = [
19
            'menu_id' => $menu->id,
20
            'position' => 0,
21
            'target' => '_self',
22
            'module_name' => 'blog',
23
            'en' => [
24
                'status' => 1,
25
                'title' => 'First Menu Item',
26
                'uri' => 'item1',
27
            ],
28
            'fr' => [
29
                'status' => 1,
30
                'title' => 'Premier item de menu',
31
                'uri' => 'item1',
32
            ],
33
        ];
34
35
        $menuItem = $this->menuItem->create($data);
36
37
        $this->assertEquals(null, $menuItem->parent_id);
38
    }
39
40
    /** @test */
41
    public function it_destroys_menu_item()
42
    {
43
        // Prepare
44
        $menu1 = $this->createMenu('main', 'Main menu');
45
        $item1 = $this->createMenuItemForMenu($menu1->id, 0);
0 ignored issues
show
Unused Code introduced by
$item1 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...
46
        $item2 = $this->createMenuItemForMenu($menu1->id, 1);
47
        $item3 = $this->createMenuItemForMenu($menu1->id, 3);
0 ignored issues
show
Unused Code introduced by
$item3 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...
48
49
        $menu2 = $this->createMenu('footer', 'Footer menu');
50
        $secondaryItem1 = $this->createMenuItemForMenu($menu2->id, 0);
0 ignored issues
show
Unused Code introduced by
$secondaryItem1 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...
51
        $secondaryItem2 = $this->createMenuItemForMenu($menu2->id, 1);
0 ignored issues
show
Unused Code introduced by
$secondaryItem2 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...
52
        $secondaryItem3 = $this->createMenuItemForMenu($menu2->id, 3);
0 ignored issues
show
Unused Code introduced by
$secondaryItem3 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...
53
54
        $this->assertEquals(6, $this->menuItem->all()->count());
55
        $this->menuItem->destroy($item2);
56
        $this->assertEquals(5, $this->menuItem->all()->count());
57
    }
58
}
59