Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
HintTest.php
Go to the documentation of this file.
1 <?php
7 
11 use PHPUnit_Framework_MockObject_MockObject as MockObject;
12 
16 class HintTest extends \PHPUnit\Framework\TestCase
17 {
21  private $block;
22 
26  private $element;
27 
28  protected function setUp()
29  {
30  $om = new ObjectManager($this);
31 
32  $this->element = $this->getMockBuilder(AbstractElement::class)
33  ->setMethods(['getComment', 'getHtmlId'])
34  ->disableOriginalConstructor()
35  ->getMockForAbstractClass();
36 
37  $this->block = $om->getObject(Hint::class);
38  }
39 
43  public function testRender()
44  {
45  $expected = '<tr id="row_payment"><td colspan="1"><p class="note"><span>';
46  $expected .= '<a href="http://test.com" target="_blank">Configuration Details</a>';
47  $expected .= '</span></p></td></tr>';
48 
49  $this->element->expects(static::exactly(2))
50  ->method('getComment')
51  ->willReturn('http://test.com');
52 
53  $this->element->expects(static::once())
54  ->method('getHtmlId')
55  ->willReturn('payment');
56 
57  static::assertSame($expected, $this->block->render($this->element));
58  }
59 
63  public function testRenderEmptyComment()
64  {
65  $this->element->expects(static::once())
66  ->method('getComment')
67  ->willReturn('');
68 
69  $this->element->expects(static::never())
70  ->method('getHtmlId');
71 
72  static::assertSame('', $this->block->render($this->element));
73  }
74 }
$om