Ejemplo n.º 1
0
 public function testEvaluate()
 {
     $input = ['interpreter' => 'one', 'value' => 'test'];
     $expected = ['value' => 'test (updated)'];
     $this->_interpreterOne->expects($this->once())->method('evaluate')->with(['value' => 'test'])->will($this->returnValue($expected));
     $this->assertSame($expected, $this->_model->evaluate($input));
 }
Ejemplo n.º 2
0
 /**
  * @param array $input
  * @param array $expected
  *
  * @dataProvider evaluateDataProvider
  */
 public function testEvaluate(array $input, array $expected)
 {
     $this->_itemInterpreter->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($input) {
         return '-' . $input['value'] . '-';
     }));
     $actual = $this->_model->evaluate($input);
     $this->assertSame($expected, $actual);
 }
Ejemplo n.º 3
0
 public function testEvaluate()
 {
     $input = array('param' => array('param1' => array('value' => 'value 1'), 'param2' => array('value' => 'value 2')));
     $this->_interpreter->expects($this->at(0))->method('evaluate')->with(array('value' => 'value 1'))->will($this->returnValue('value 1 (evaluated)'));
     $this->_interpreter->expects($this->at(1))->method('evaluate')->with(array('value' => 'value 2'))->will($this->returnValue('value 2 (evaluated)'));
     $expected = array('param1' => 'value 1 (evaluated)', 'param2' => 'value 2 (evaluated)');
     $actual = $this->_model->evaluate($input);
     $this->assertSame($expected, $actual);
 }
Ejemplo n.º 4
0
 public function testEvaluateNoUpdaters()
 {
     $input = ['value' => 'some text'];
     $expected = ['value' => 'new text'];
     $this->_interpreter->expects($this->once())->method('evaluate')->with($input)->will($this->returnValue($expected));
     $this->_objectManager->expects($this->never())->method('get');
     $actual = $this->_model->evaluate($input);
     $this->assertSame($expected, $actual);
 }
Ejemplo n.º 5
0
 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);
 }
Ejemplo n.º 6
0
 /**
  * @dataProvider getComponentDataProvider()
  */
 public function testCreateRawComponentData($componentName, $configData, $componentData, $needEvaluate)
 {
     $this->componentConfigProvider->expects($this->any())->method('getComponentData')->willReturn($configData);
     if ($needEvaluate === true) {
         $this->argumentInterpreter->expects($this->once())->method('evaluate')->willReturnCallback(function ($argument) {
             return ['argument' => $argument['value']];
         });
     } else {
         $this->argumentInterpreter->expects($this->never())->method('evaluate');
     }
     $this->assertEquals($componentData, $this->manager->createRawComponentData($componentName, $needEvaluate));
 }