_layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get( \Magento\Framework\View\LayoutInterface::class ); $this->_block = $this->_layout->createBlock(\Magento\Sales\Block\Order\Invoice\Items::class, 'block'); $this->_invoice = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Sales\Model\Order\Invoice::class ); } /** * @magentoAppIsolation enabled */ public function testGetInvoiceTotalsHtml() { $childBlock = $this->_layout->addBlock(\Magento\Framework\View\Element\Text::class, 'invoice_totals', 'block'); $expectedHtml = 'Any html'; $this->assertEmpty($childBlock->getInvoice()); $this->assertNotEquals($expectedHtml, $this->_block->getInvoiceTotalsHtml($this->_invoice)); $childBlock->setText($expectedHtml); $actualHtml = $this->_block->getInvoiceTotalsHtml($this->_invoice); $this->assertSame($this->_invoice, $childBlock->getInvoice()); $this->assertEquals($expectedHtml, $actualHtml); } public function testGetInvoiceCommentsHtml() { $childBlock = $this->_layout->addBlock( \Magento\Framework\View\Element\Text::class, 'invoice_comments', 'block' ); $expectedHtml = 'Any html'; $this->assertEmpty($childBlock->getEntity()); $this->assertEmpty($childBlock->getTitle()); $this->assertNotEquals($expectedHtml, $this->_block->getInvoiceCommentsHtml($this->_invoice)); $childBlock->setText($expectedHtml); $actualHtml = $this->_block->getInvoiceCommentsHtml($this->_invoice); $this->assertSame($this->_invoice, $childBlock->getEntity()); $this->assertNotEmpty($childBlock->getTitle()); $this->assertEquals($expectedHtml, $actualHtml); } }