Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
QtyTest.php
Go to the documentation of this file.
1 <?php
7 
8 class QtyTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $renderer;
14 
18  protected $rowMock;
19 
23  protected $typeConfigMock;
24 
25  protected function setUp()
26  {
27  $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
28 
29  $this->rowMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getTypeId', 'getIndex']);
30  $this->typeConfigMock = $this->createMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class);
31  $this->renderer = $helper->getObject(
32  \Magento\Sales\Block\Adminhtml\Order\Create\Search\Grid\Renderer\Qty::class,
33  ['typeConfig' => $this->typeConfigMock]
34  );
35  }
36 
37  public function testRender()
38  {
39  $expected = '<input type="text" name="id_name" value="" disabled="disabled" ' .
40  'class="input-text admin__control-text inline_css input-inactive" />';
41  $this->typeConfigMock->expects(
42  $this->any()
43  )->method(
44  'isProductSet'
45  )->with(
46  'id'
47  )->will(
48  $this->returnValue(true)
49  );
50  $this->rowMock->expects($this->once())->method('getTypeId')->will($this->returnValue('id'));
51  $columnMock = $this->createPartialMock(
52  \Magento\Backend\Block\Widget\Grid\Column::class,
53  ['getInlineCss', 'getId']
54  );
55  $this->renderer->setColumn($columnMock);
56 
57  $columnMock->expects($this->once())->method('getId')->will($this->returnValue('id_name'));
58  $columnMock->expects($this->once())->method('getInlineCss')->will($this->returnValue('inline_css'));
59 
60  $this->assertEquals($expected, $this->renderer->render($this->rowMock));
61  }
62 }
$helper
Definition: iframe.phtml:13