public function testToHtml() { $this->assertEmpty($this->_block->getProductCollection()); $this->_block->setProductsCount(5); $this->_block->setTemplate('product/widget/new/content/new_list.phtml'); $this->_block->setLayout(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')); $html = $this->_block->toHtml(); $this->assertNotEmpty($html); $this->assertContains('New Product', $html); $this->assertInstanceOf('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection', $this->_block->getProductCollection()); }