resolver = $this->createMock(\Magento\Framework\View\Element\Template\File\Resolver::class); $this->validator = $this->createMock(\Magento\Framework\View\Element\Template\File\Validator::class); $this->rootDirMock = $this->createMock(\Magento\Framework\Filesystem\Directory\Read::class); $this->rootDirMock->expects($this->any()) ->method('getRelativePath') ->willReturnArgument(0); $this->filesystem = $this->createMock(\Magento\Framework\Filesystem::class); $this->filesystem->expects($this->any()) ->method('getDirectoryRead') ->with(DirectoryList::ROOT, DriverPool::FILE) ->willReturn($this->rootDirMock); $this->templateEngine = $this->createPartialMock( \Magento\Framework\View\TemplateEnginePool::class, ['render', 'get'] ); $this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class); $this->templateEngine->expects($this->any())->method('get')->willReturn($this->templateEngine); $this->appState = $this->createPartialMock(\Magento\Framework\App\State::class, ['getAreaCode', 'getMode']); $this->appState->expects($this->any())->method('getAreaCode')->willReturn('frontend'); $storeManagerMock = $this->createMock(StoreManager::class); $storeMock = $this->createMock(Store::class); $storeManagerMock->expects($this->any()) ->method('getStore') ->willReturn($storeMock); $storeMock->expects($this->any()) ->method('getCode') ->willReturn('storeCode'); $urlBuilderMock = $this->createMock(UrlInterface::class); $urlBuilderMock->expects($this->any()) ->method('getBaseUrl') ->willReturn('baseUrl'); $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->block = $helper->getObject( \Magento\Framework\View\Element\Template::class, [ 'filesystem' => $this->filesystem, 'enginePool' => $this->templateEngine, 'resolver' => $this->resolver, 'validator' => $this->validator, 'appState' => $this->appState, 'logger' => $this->loggerMock, 'storeManager' => $storeManagerMock, 'urlBuilder' => $urlBuilderMock, 'data' => ['template' => 'template.phtml', 'module_name' => 'Fixture_Module'] ] ); } public function testGetTemplateFile() { $params = ['module' => 'Fixture_Module', 'area' => 'frontend']; $this->resolver->expects($this->once())->method('getTemplateFileName')->with('template.phtml', $params); $this->block->getTemplateFile(); } public function testFetchView() { $this->expectOutputString(''); $template = 'themedir/template.phtml'; $this->validator->expects($this->once()) ->method('isValid') ->with($template) ->willReturn(true); $output = '