/** * @dataProvider processDataProvider */ public function testProcess($xml) { $this->element = new \Magento\Framework\View\Layout\Element($xml); $this->context->expects($this->any())->method('getScheduledStructure')->will($this->returnValue($this->scheduledStructure)); $this->scheduledStructure->expects($this->once())->method('setElementToRemoveList')->with('header'); $this->model->interpret($this->context, $this->element, $this->element); }
protected function setUp() { $this->objectManagerHelper = new ObjectManagerHelper($this); $this->scheduledStructureMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\ScheduledStructure')->disableOriginalConstructor()->getMock(); $this->contextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock(); $this->contextMock->expects($this->any())->method('getScheduledStructure')->willReturn($this->scheduledStructureMock); $this->move = $this->objectManagerHelper->getObject('Magento\\Framework\\View\\Layout\\Reader\\Move'); }
/** * * @param \Magento\Framework\View\Layout\Element $element * * @dataProvider interpretDataProvider */ public function testInterpret($element) { $scheduleStructure = $this->getMock('\\Magento\\Framework\\View\\Layout\\ScheduledStructure', [], [], '', false); $this->context->expects($this->any())->method('getScheduledStructure')->will($this->returnValue($scheduleStructure)); $this->helper->expects($this->any())->method('scheduleStructure')->with($scheduleStructure, $element, $element->getParent())->willReturn($element->getAttribute('name')); $scheduleStructure->expects($this->once())->method('setStructureElementData')->with($element->getAttribute('name'), ['attributes' => ['group' => '', 'component' => 'listing']]); $scheduleStructure->expects($this->once())->method('setElementToIfconfigList')->with($element->getAttribute('name'), 'config_path', 'scope'); $this->model->interpret($this->context, $element); }
/** * @return void */ protected function setUp() { // ScheduledStructure $this->readerContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock(); $this->scheduledStructure = new ScheduledStructure(); $this->readerContextMock->expects($this->any())->method('getScheduledStructure')->willReturn($this->scheduledStructure); // DataStructure $this->generatorContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Generator\\Context')->disableOriginalConstructor()->getMock(); $this->structureMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Data\\Structure')->disableOriginalConstructor()->setMethods(['reorderChildElement'])->getMock(); $this->generatorContextMock->expects($this->any())->method('getStructure')->willReturn($this->structureMock); $this->helperMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\ScheduledStructure\\Helper')->disableOriginalConstructor()->getMock(); $helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->model = $helperObjectManager->getObject('Magento\\Framework\\View\\Layout\\GeneratorPool', ['helper' => $this->helperMock, 'generators' => $this->getGeneratorsMocks()]); }
public function testProcess() { $this->prepareScheduledStructure(); $this->readerContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Reader\\Context')->disableOriginalConstructor()->getMock(); $this->readerContextMock->expects($this->any())->method('getScheduledStructure')->willReturn($this->scheduledStructureMock); $generatorContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Generator\\Context')->disableOriginalConstructor()->getMock(); $structureMock = $this->getMockBuilder('Magento\\Framework\\View\\Layout\\Data\\Structure')->disableOriginalConstructor()->getMock(); $structureMock->expects($this->once())->method('addToParentGroup')->with(UiComponent::TYPE, 'new_group')->willReturnSelf(); $layoutMock = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->getMockForAbstractClass(); $generatorContextMock->expects($this->any())->method('getStructure')->willReturn($structureMock); $generatorContextMock->expects($this->any())->method('getLayout')->willReturn($layoutMock); $this->uiComponentFactoryMock->expects($this->any())->method('setLayout')->with($layoutMock)->willReturnSelf(); $blockMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\AbstractBlock')->disableOriginalConstructor()->getMock(); $this->uiComponentFactoryMock->expects($this->any())->method('createUiComponent')->with('component_name', UiComponent::TYPE, ['attribute_1' => 'value_1', 'attribute_2' => 'value_2'])->willReturn($blockMock); $this->argumentInterpreterMock->expects($this->any())->method('evaluate')->will($this->returnValueMap([[['key_1' => 'value_1'], 'value_1'], [['key_2' => 'value_2'], 'value_2']])); $layoutMock->expects($this->any())->method('setBlock')->with(UiComponent::TYPE, $blockMock)->willReturnSelf(); $this->uiComponent->process($this->readerContextMock, $generatorContextMock); }
/** * @param string $literal * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $getCondition * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setCondition * @dataProvider processReferenceDataProvider */ public function testProcessReference($literal, $getCondition, $setCondition) { $this->context->expects($this->once())->method('getScheduledStructure')->will($this->returnValue($this->scheduledStructure)); $this->scheduledStructure->expects($getCondition)->method('getStructureElementData')->with($literal, [])->willReturn(['actions' => [['someMethod', [], 'action_config_path', 'scope']]]); $this->scheduledStructure->expects($setCondition)->method('setStructureElementData')->with($literal, ['actions' => [['someMethod', [], 'action_config_path', 'scope']], 'arguments' => []]); $this->prepareReaderPool('<' . $literal . ' name="' . $literal . '">' . '<action method="someMethod" ifconfig="action_config_path" />' . '</' . $literal . '>', $literal); /** @var \Magento\Framework\View\Layout\Reader\Block $block */ $block = $this->getBlock(['readerPool' => $this->readerPool, 'scopeType' => 'scope']); $block->interpret($this->context, $this->currentElement); }
/** * @covers Magento\Framework\View\Layout\Reader\Block::interpret() */ public function testProcessReference() { $testName = 'test_value'; $literal = 'referenceBlock'; $this->context->expects($this->once())->method('getScheduledStructure')->will($this->returnValue($this->scheduledStructure)); $this->scheduledStructure->expects($this->once())->method('getStructureElementData')->with($testName, [])->will($this->returnValue([])); $this->scheduledStructure->expects($this->once())->method('setStructureElementData')->with($testName, ['actions' => [], 'arguments' => []]); $this->prepareReaderPool('<' . $literal . ' name="' . $testName . '"/>'); /** @var \Magento\Framework\View\Layout\Reader\Block $block */ $block = $this->getBlock(['readerPool' => $this->readerPool]); $block->interpret($this->context, $this->currentElement); }