ItemsTest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Order\Invoice;
  7. class ItemsTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\View\LayoutInterface
  11. */
  12. protected $_layout;
  13. /**
  14. * @var \Magento\Sales\Block\Order\Invoice\Items
  15. */
  16. protected $_block;
  17. /**
  18. * @var \Magento\Sales\Model\Order\Invoice
  19. */
  20. protected $_invoice;
  21. protected function setUp()
  22. {
  23. $this->_layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  24. \Magento\Framework\View\LayoutInterface::class
  25. );
  26. $this->_block = $this->_layout->createBlock(\Magento\Sales\Block\Order\Invoice\Items::class, 'block');
  27. $this->_invoice = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  28. \Magento\Sales\Model\Order\Invoice::class
  29. );
  30. }
  31. /**
  32. * @magentoAppIsolation enabled
  33. */
  34. public function testGetInvoiceTotalsHtml()
  35. {
  36. $childBlock = $this->_layout->addBlock(\Magento\Framework\View\Element\Text::class, 'invoice_totals', 'block');
  37. $expectedHtml = '<b>Any html</b>';
  38. $this->assertEmpty($childBlock->getInvoice());
  39. $this->assertNotEquals($expectedHtml, $this->_block->getInvoiceTotalsHtml($this->_invoice));
  40. $childBlock->setText($expectedHtml);
  41. $actualHtml = $this->_block->getInvoiceTotalsHtml($this->_invoice);
  42. $this->assertSame($this->_invoice, $childBlock->getInvoice());
  43. $this->assertEquals($expectedHtml, $actualHtml);
  44. }
  45. public function testGetInvoiceCommentsHtml()
  46. {
  47. $childBlock = $this->_layout->addBlock(
  48. \Magento\Framework\View\Element\Text::class,
  49. 'invoice_comments',
  50. 'block'
  51. );
  52. $expectedHtml = '<b>Any html</b>';
  53. $this->assertEmpty($childBlock->getEntity());
  54. $this->assertEmpty($childBlock->getTitle());
  55. $this->assertNotEquals($expectedHtml, $this->_block->getInvoiceCommentsHtml($this->_invoice));
  56. $childBlock->setText($expectedHtml);
  57. $actualHtml = $this->_block->getInvoiceCommentsHtml($this->_invoice);
  58. $this->assertSame($this->_invoice, $childBlock->getEntity());
  59. $this->assertNotEmpty($childBlock->getTitle());
  60. $this->assertEquals($expectedHtml, $actualHtml);
  61. }
  62. }