Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StructureManagerTest.php
Go to the documentation of this file.
1 <?php
8 
13 
17 class StructureManagerTest extends \PHPUnit\Framework\TestCase
18 {
22  private $structureMock;
23 
27  private $scheduledStructureMock;
28 
32  private $structureManager;
33 
34  public function setUp()
35  {
36  $objectManager = new ObjectManager($this);
37  $this->structureMock = $this->getMockBuilder(Structure::class)
38  ->disableOriginalConstructor()
39  ->getMock();
40  $this->scheduledStructureMock = $this->getMockBuilder(ScheduledStructure::class)
41  ->disableOriginalConstructor()
42  ->getMock();
43  $this->structureManager = $objectManager->getObject(StructureManager::class);
44  }
45 
46  public function testRemoveElement()
47  {
48  $this->structureMock->expects($this->exactly(3))
49  ->method('getChildren')
50  ->willReturnMap(
51  [
52  [
53  'element-0', [
54  'element-1' => [],
55  'element-2' => []
56  ]
57  ],
58  [
59  'element-1', []
60  ],
61  [
62  'element-2', []
63  ]
64  ]
65  );
66  $this->scheduledStructureMock->expects($this->exactly(3))
67  ->method('unsetElement')
68  ->willReturnMap(
69  [
70  ['element-0', true],
71  ['element-1', true],
72  ['element-2', true]
73  ]
74  );
75  $this->structureMock->expects($this->once())
76  ->method('unsetElement')
77  ->with('element-0');
78  $this->assertTrue(
79  $this->structureManager->removeElement(
80  $this->scheduledStructureMock,
81  $this->structureMock,
82  'element-0',
83  false
84  )
85  );
86  }
87 }
$objectManager
Definition: bootstrap.php:17