Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CommentsTest.php
Go to the documentation of this file.
1 <?php
7 
8 class CommentsTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $_block;
14 
15  protected function setUp()
16  {
18  \Magento\Framework\View\LayoutInterface::class
19  )->createBlock(
20  \Magento\Sales\Block\Order\Comments::class
21  );
22  }
23 
29  public function testGetComments($commentedEntity, $expectedClass)
30  {
31  $commentedEntity = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create($commentedEntity);
32  $this->_block->setEntity($commentedEntity);
33  $comments = $this->_block->getComments();
34  $this->assertInstanceOf($expectedClass, $comments);
35  }
36 
40  public function getCommentsDataProvider()
41  {
42  return [
43  [
44  \Magento\Sales\Model\Order\Invoice::class,
45  \Magento\Sales\Model\ResourceModel\Order\Invoice\Comment\Collection::class,
46  ],
47  [
48  \Magento\Sales\Model\Order\Creditmemo::class,
49  \Magento\Sales\Model\ResourceModel\Order\Creditmemo\Comment\Collection::class
50  ],
51  [
52  \Magento\Sales\Model\Order\Shipment::class,
53  \Magento\Sales\Model\ResourceModel\Order\Shipment\Comment\Collection::class
54  ]
55  ];
56  }
57 
62  {
64  \Magento\Catalog\Model\Product::class
65  );
66  $this->_block->setEntity($entity);
67  $this->_block->getComments();
68  }
69 }
testGetComments($commentedEntity, $expectedClass)
$entity
Definition: element.phtml:22