MenuTest::testName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
c 0
b 0
f 0
rs 9.6666
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Alpixel\Bundle\MenuBundle\Tests\Entity;
4
5
use Alpixel\Bundle\MenuBundle\Entity\Item;
6
use Alpixel\Bundle\MenuBundle\Entity\Menu;
7
use Doctrine\Common\Collections\ArrayCollection;
8
9
class MenuTest extends \PHPUnit_Framework_TestCase
10
{
11 View Code Duplication
    public function testToString()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
    {
13
        $menu = $this->getMenuInstance();
14
        $this->assertNull($menu->__toString());
15
16
        $test = 'Menu principal';
17
        $menu->setMachineName($test);
18
        $this->assertEquals($test, $menu->__toString());
19
    }
20
21 View Code Duplication
    public function testMachineName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        $menu = $this->getMenuInstance();
24
        $this->assertNull($menu->getMachineName());
25
26
        $test = 'main';
27
        $menu->setMachineName($test);
28
        $this->assertEquals($test, $menu->getMachineName());
29
    }
30
31 View Code Duplication
    public function testName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        $menu = $this->getMenuInstance();
34
        $this->assertNull($menu->getName());
35
36
        $test = 'Menu principal';
37
        $menu->setName($test);
38
        $this->assertEquals($test, $menu->getName());
39
    }
40
41
    public function testLocale()
42
    {
43
        $menu = $this->getMenuInstance();
44
        $this->assertNull($menu->getLocale());
45
46
        $test = 'fr';
47
        $menu->setLocale($test);
48
        $this->assertEquals($test, $menu->getLocale());
49
    }
50
51 View Code Duplication
    public function testItems()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $menu = $this->getMenuInstance();
54
        $this->assertInstanceOf(ArrayCollection::class, $menu->getItems());
55
        $this->assertCount(0, $menu->getItems());
56
57
        $menu->setItem($this->getItemInstance());
0 ignored issues
show
Deprecated Code introduced by
The method Alpixel\Bundle\MenuBundle\Entity\Menu::setItem() has been deprecated.

This method has been deprecated.

Loading history...
58
        $this->assertInstanceOf(ArrayCollection::class, $menu->getItems());
59
        $this->assertCount(1, $menu->getItems());
60
61
        $this->assertCount(1, $menu->getItems()->toArray());
62
        $this->assertInstanceOf(Item::class, $menu->getItems()->first());
63
64
        $menu->removeItem($menu->getItems()->first());
65
        $this->assertCount(0, $menu->getItems()->toArray());
66
67
        $collection = new ArrayCollection();
68
        $collection->add($this->getItemInstance());
69
        $collection->add($this->getItemInstance());
70
        $menu->addItems($collection);
71
        $this->assertCount(2, $menu->getItems()->toArray());
72
    }
73
74
    public function getItemInstance()
75
    {
76
        return new Item();
77
    }
78
79
    public function getMenuInstance()
80
    {
81
        return new Menu();
82
    }
83
}
84