| @@ 69-90 (lines=22) @@ | ||
| 66 | $this->assertInstanceOf(Item::class, $item->getParent()); |
|
| 67 | } |
|
| 68 | ||
| 69 | public function testChildren() |
|
| 70 | { |
|
| 71 | $item = $this->getItemInstance(); |
|
| 72 | $this->assertInstanceOf(ArrayCollection::class, $item->getChildren()); |
|
| 73 | $this->assertCount(0, $item->getchildren()); |
|
| 74 | ||
| 75 | $item->setChildren($this->getItemInstance()); |
|
| 76 | $this->assertInstanceOf(ArrayCollection::class, $item->getChildren()); |
|
| 77 | $this->assertCount(1, $item->getChildren()); |
|
| 78 | $this->assertCount(1, $item->getChildren()->toArray()); |
|
| 79 | ||
| 80 | $this->assertInstanceOf(Item::class, $item->getChildren()->first()); |
|
| 81 | ||
| 82 | $item->removeChildren($item->getChildren()->first()); |
|
| 83 | $this->assertCount(0, $item->getChildren()->toArray()); |
|
| 84 | ||
| 85 | $collection = new ArrayCollection(); |
|
| 86 | $collection->add($this->getItemInstance()); |
|
| 87 | $collection->add($this->getItemInstance()); |
|
| 88 | $item->addChildren($collection); |
|
| 89 | $this->assertCount(2, $item->getChildren()->toArray()); |
|
| 90 | } |
|
| 91 | ||
| 92 | public function getItemInstance() |
|
| 93 | { |
|
| @@ 51-72 (lines=22) @@ | ||
| 48 | $this->assertEquals($test, $menu->getLocale()); |
|
| 49 | } |
|
| 50 | ||
| 51 | public function testItems() |
|
| 52 | { |
|
| 53 | $menu = $this->getMenuInstance(); |
|
| 54 | $this->assertInstanceOf(ArrayCollection::class, $menu->getItems()); |
|
| 55 | $this->assertCount(0, $menu->getItems()); |
|
| 56 | ||
| 57 | $menu->setItem($this->getItemInstance()); |
|
| 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 | { |
|