46 $this->cellParameters = [
48 'style' =>
'testStyle',
49 'class' =>
'testClass',
52 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
54 $this->labelFactoryMock = $this->getMockBuilder(\
Magento\Framework\View\Design\Theme\LabelFactory::class)
55 ->disableOriginalConstructor()
57 $this->labelMock = $this->getMockBuilder(\
Magento\Framework\View\Design\Theme\Label::class)
58 ->disableOriginalConstructor()
60 $this->elementFactoryMock = $this->getMockBuilder(\
Magento\Framework\Data\Form\Element\Factory::class)
61 ->disableOriginalConstructor()
63 $this->elementMock = $this->getMockBuilder(\
Magento\Framework\Data\Form\Element\AbstractElement::class)
64 ->disableOriginalConstructor()
66 [
'setForm',
'setName',
'setHtmlId',
'setValues',
'getName',
'getHtmlId',
'getValues',
'getElementHtml']
78 \
Magento\Config\Block\System\Config\Form\Field\Regexceptions::class,
85 $columnName =
'value';
86 $expectedResult =
'testValueElementHtml';
88 $this->elementFactoryMock->expects($this->once())->method(
'create')->willReturn($this->elementMock);
89 $this->elementMock->expects($this->once())->method(
'setForm')->willReturnSelf();
90 $this->elementMock->expects($this->once())->method(
'setName')->willReturnSelf();
91 $this->elementMock->expects($this->once())->method(
'setHtmlId')->willReturnSelf();
92 $this->elementMock->expects($this->once())->method(
'setValues')->willReturnSelf();
93 $this->elementMock->expects($this->once())->method(
'getElementHtml')->willReturn($expectedResult);
95 $this->labelFactoryMock->expects($this->once())->method(
'create')->willReturn($this->labelMock);
96 $this->labelMock->expects($this->once())->method(
'getLabelsCollection')->willReturn([]);
98 $this->
object->addColumn(
100 $this->cellParameters
105 $this->object->renderCellTemplate($columnName)
111 $columnName =
'testCellName';
113 $this->
object->addColumn(
115 $this->cellParameters
118 $actual = $this->
object->renderCellTemplate($columnName);
119 foreach ($this->cellParameters as $parameter) {
120 $this->assertContains($parameter, $actual,
'Parameter \'' . $parameter .
'\' missing in render
output.
'); 124 public function testRenderCellTemplateWrongColumnName() 126 $columnName = 'testCellName
'; 127 $wrongColumnName = 'wrongTestCellName
'; 129 $this->object->addColumn($wrongColumnName, $this->cellParameters); 131 $this->expectException('\Exception
'); 132 $this->expectExceptionMessage('Wrong column
name specified.
'); 134 $this->object->renderCellTemplate($columnName); output($string, $level=INFO, $label='')