Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConcatTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class ConcatTest extends \PHPUnit\Framework\TestCase
11 {
14 
16  protected $renderer;
17 
18  protected function setUp()
19  {
20  $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
21  $this->renderer = $this->objectManagerHelper->getObject(
22  \Magento\Backend\Block\Widget\Grid\Column\Renderer\Concat::class
23  );
24  }
25 
29  public function typeProvider()
30  {
31  return [
32  ['getGetter', ['getTest', 'getBest']],
33  ['getIndex', ['test', 'best', 'nothing']],
34  ];
35  }
36 
40  public function testRender($method, $getters)
41  {
42  $object = new DataObject(['test' => 'a', 'best' => 'b']);
43  $column = $this->createPartialMock(\Magento\Backend\Block\Widget\Grid\Column::class, [$method, 'getSeparator']);
44  $column->expects($this->any())
45  ->method('getSeparator')
46  ->will($this->returnValue('-'));
47  $column->expects($this->any())
48  ->method($method)
49  ->will($this->returnValue($getters));
50  if ($method == 'getGetter') {
51  $column->expects($this->any())
52  ->method('getGetter')
53  ->willReturn(['getTest', 'getBest']);
54  }
55  $this->renderer->setColumn($column);
56  $this->assertEquals('a-b', $this->renderer->render($object));
57  }
58 }
$method
Definition: info.phtml:13