Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NoteTest.php
Go to the documentation of this file.
1 <?php
11 
12 class NoteTest extends \PHPUnit\Framework\TestCase
13 {
18 
22  protected $_model;
23 
24  protected function setUp()
25  {
26  $factoryMock = $this->createMock(\Magento\Framework\Data\Form\Element\Factory::class);
27  $collectionFactoryMock = $this->createMock(\Magento\Framework\Data\Form\Element\CollectionFactory::class);
28  $escaperMock = $this->createMock(\Magento\Framework\Escaper::class);
29  $this->_model = new \Magento\Framework\Data\Form\Element\Note(
30  $factoryMock,
31  $collectionFactoryMock,
32  $escaperMock
33  );
34  $formMock = new \Magento\Framework\DataObject();
35  $formMock->getHtmlIdPrefix('id_prefix');
36  $formMock->getHtmlIdPrefix('id_suffix');
37  $this->_model->setForm($formMock);
38  }
39 
43  public function testConstruct()
44  {
45  $this->assertEquals('note', $this->_model->getType());
46  }
47 
51  public function testGetElementHtml()
52  {
53  $this->_model->setBeforeElementHtml('note_before');
54  $this->_model->setAfterElementHtml('note_after');
55  $this->_model->setId('note_id');
56  $this->_model->setData('ui_id', 'ui_id');
57  $this->_model->setValue('Note Text');
58  $html = $this->_model->getElementHtml();
59  $this->assertEquals(
60  "note_before<div id=\"note_id\" class=\"control-value admin__field-value\"></div>note_after",
61  $html
62  );
63  }
64 }