public function testGetBlockHtml() { // Without layout /** @var $blockFactory \Magento\Framework\View\Element\BlockFactory */ $blockFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\Element\\BlockFactory'); $block1 = $blockFactory->createBlock('Magento\\Framework\\View\\Element\\Text'); $block1->setText('Block text'); $block1->setNameInLayout('block'); $html = $this->_block->getBlockHtml('block'); $this->assertInternalType('string', $html); $this->assertEmpty($html); // With layout $expected = 'Block2'; $block2 = $this->_createBlockWithLayout('block2', 'block2', 'Magento\\Framework\\View\\Element\\Text'); $block3 = $this->_createBlockWithLayout('block3', 'block3'); $block2->setText($expected); $html = $block3->getBlockHtml('block2'); $this->assertInternalType('string', $html); $this->assertEquals($expected, $html); }