ItemsTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Shipping\Block;
  7. class ItemsTest extends \PHPUnit\Framework\TestCase
  8. {
  9. public function testGetCommentsHtml()
  10. {
  11. $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  12. \Magento\Framework\View\LayoutInterface::class
  13. );
  14. $block = $layout->createBlock(\Magento\Shipping\Block\Items::class, 'block');
  15. $childBlock = $layout->addBlock(\Magento\Framework\View\Element\Text::class, 'shipment_comments', 'block');
  16. $shipment = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  17. \Magento\Sales\Model\Order\Shipment::class
  18. );
  19. $expectedHtml = '<b>Any html</b>';
  20. $this->assertEmpty($childBlock->getEntity());
  21. $this->assertEmpty($childBlock->getTitle());
  22. $this->assertNotEquals($expectedHtml, $block->getCommentsHtml($shipment));
  23. $childBlock->setText($expectedHtml);
  24. $actualHtml = $block->getCommentsHtml($shipment);
  25. $this->assertSame($shipment, $childBlock->getEntity());
  26. $this->assertNotEmpty($childBlock->getTitle());
  27. $this->assertEquals($expectedHtml, $actualHtml);
  28. }
  29. }