/** * @covers \Magento\Framework\View\Element\AbstractBlock::toHtml * @see testAssign() */ public function testToHtml() { \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->setAreaCode('any area'); $this->assertEmpty($this->_block->toHtml()); $this->_block->setTemplate(uniqid('invalid_filename.phtml')); $this->assertEmpty($this->_block->toHtml()); }
public function testFetchViewWithNoFileName() { $output = ''; $template = false; $templatePath = 'wrong_template_path.pthml'; $moduleName = 'Acme'; $blockName = 'acme_test_module_test_block'; $exception = "Invalid template file: '{$templatePath}' in module: '{$moduleName}' block's name: '{$blockName}'"; $this->block->setTemplate($templatePath); $this->block->setData('module_name', $moduleName); $this->block->setNameInLayout($blockName); $this->validator->expects($this->once())->method('isValid')->with($template)->willReturn(false); $this->loggerMock->expects($this->once())->method('critical')->with($exception)->willReturn(null); $this->assertEquals($output, $this->block->fetchView($template)); }
/** * {@inheritdoc} * * @param string $template * @return $this */ public function setTemplate($template) { if (!empty($template)) { parent::setTemplate($template); } return $this; }
/** * @param OriginalBloc $baseImage * @param Template $block * @return Template * * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterCreateElementHtmlOutputBlock(OriginalBloc $baseImage, Template $block) { $block->setTemplate(self::ELEMENT_OUTPUT_TEMPLATE); return $block; }