9 use \Magento\Framework\View\Layout\Generator\UiComponent;
62 $this->objectManagerHelper =
new ObjectManagerHelper($this);
63 $this->argumentInterpreterMock = $this->getMockBuilder(
64 \
Magento\Framework\
Data\Argument\InterpreterInterface::class
65 )->disableOriginalConstructor()->getMockForAbstractClass();
66 $this->uiComponentFactoryMock = $this->getMockBuilder(\
Magento\Framework\
View\
Element\UiComponentFactory::class)
67 ->setMethods([
'setLayout',
'create'])
68 ->disableOriginalConstructor()->getMock();
69 $this->scheduledStructureMock = $this->getMockBuilder(\
Magento\Framework\
View\
Layout\ScheduledStructure::class)
70 ->disableOriginalConstructor()->getMock();
71 $this->contextFactoryMock =
73 $this->blockFactoryMock = $this->createMock(\
Magento\Framework\
View\
Element\BlockFactory::class);
75 $this->uiComponent = $this->objectManagerHelper->getObject(
78 'uiComponentFactory' => $this->uiComponentFactoryMock,
79 'blockFactory' => $this->blockFactoryMock,
80 'contextFactory' => $this->contextFactoryMock
89 $this->readerContextMock = $this->getMockBuilder(\
Magento\Framework\
View\
Layout\Reader\Context::class)
90 ->disableOriginalConstructor()->getMock();
92 $this->readerContextMock->expects($this->any())
93 ->method(
'getScheduledStructure')
94 ->willReturn($this->scheduledStructureMock);
96 $generatorContextMock = $this->getMockBuilder(\
Magento\Framework\
View\
Layout\Generator\Context::class)
97 ->disableOriginalConstructor()->getMock();
100 ->disableOriginalConstructor()->getMock();
102 $structureMock->expects($this->once())
103 ->method(
'addToParentGroup')
107 $layoutMock = $this->getMockBuilder(\
Magento\Framework\
View\LayoutInterface::class)->getMockForAbstractClass();
109 $generatorContextMock->expects($this->any())
110 ->method(
'getStructure')
111 ->willReturn($structureMock);
112 $generatorContextMock->expects($this->any())
113 ->method(
'getLayout')
114 ->willReturn($layoutMock);
116 $this->uiComponentFactoryMock->expects($this->any())
117 ->method(
'setLayout')
121 $componentMock = $this->getMockForAbstractClass(
131 $contextMock = $this->getMockForAbstractClass(
137 $blockMock = $this->getMockForAbstractClass(
144 $this->contextFactoryMock->expects($this->once())
148 'namespace' =>
'uiComponent',
149 'pageLayout' => $layoutMock
151 )->willReturn($contextMock);
153 $this->uiComponentFactoryMock->expects($this->any())
158 [
'context' => $contextMock,
'structure' => $structureMock]
159 )->willReturn($componentMock);
161 $this->blockFactoryMock->expects($this->once())
162 ->method(
'createBlock')
164 ->willReturn($blockMock);
166 $this->argumentInterpreterMock->expects($this->any())
168 ->will($this->returnValueMap([
169 [[
'key_1' =>
'value_1'],
'value_1'],
170 [[
'key_2' =>
'value_2'],
'value_2'],
173 $layoutMock->expects($this->any())
178 $this->uiComponent->process($this->readerContextMock, $generatorContextMock);
183 $this->scheduledStructureMock->expects($this->any())
184 ->method(
'getElements')
190 'group' =>
'new_group',
191 'component' =>
'component_name',
194 'attribute_1' => [
'key_1' =>
'value_1'],
195 'attribute_2' => [
'key_2' =>
'value_2'],
prepareScheduledStructure()