/** * @test */ public function testWarm() { $failedCompilingState = $this->getAccessibleMock(FailedCompilingState::class, ['dummy']); $subject = $this->getMockBuilder(StandardCacheWarmer::class)->setMethods(['warmSingleFile', 'detectControllerNamesInTemplateRootPaths'])->getMock(); $subject->expects($this->exactly(7))->method('detectControllerNamesInTemplateRootPaths')->willReturn(['Default', 'Standard']); $subject->expects($this->exactly(70))->method('warmSingleFile')->willReturn($failedCompilingState); $context = new RenderingContextFixture(); $paths = $this->getMockBuilder(TemplatePaths::class)->setMethods(['resolveAvailableTemplateFiles', 'resolveAvailablePartialFiles', 'resolveAvailableLayoutFiles', 'resolveFileInPaths'])->getMock(); $paths->expects($this->exactly(21))->method('resolveAvailableTemplateFiles')->willReturn(['foo', 'bar']); $paths->expects($this->exactly(7))->method('resolveAvailablePartialFiles')->willReturn(['foo', 'bar']); $paths->expects($this->exactly(7))->method('resolveAvailableLayoutFiles')->willReturn(['foo', 'bar']); $paths->expects($this->exactly(56))->method('resolveFileInPaths')->willReturn('/dev/null'); $compiler = $this->getMockBuilder(TemplateCompiler::class)->setMethods(['enterWarmupMode'])->getMock(); $compiler->expects($this->once())->method('enterWarmupMode'); $context->setTemplateCompiler($compiler); $context->setTemplatePaths($paths); $failedCompilingState->_set('variableContainer', new StandardVariableProvider()); $result = $subject->warm($context); $this->assertInstanceOf(FluidCacheWarmupResult::class, $result); }
/** * @test */ public function getOrParseAndStoreTemplateSetsCompilableStateAndReturnsOnStopComilingException() { $parsedTemplate = $this->getMock(ParsingState::class, array('setCompilable')); $parsedTemplate->expects($this->once())->method('setCompilable')->with(FALSE); $templateParser = $this->getMock(TemplateParser::class, array('parse')); $templateParser->expects($this->once())->method('parse')->willReturn($parsedTemplate); $context = new RenderingContextFixture(); $compiler = $this->getMock(TemplateCompiler::class, array('store', 'has')); $compiler->expects($this->once())->method('has')->willReturn(FALSE); $compiler->expects($this->once())->method('store')->willThrowException(new StopCompilingException()); $context->setTemplateCompiler($compiler); $context->setVariableProvider(new StandardVariableProvider()); $templateParser->setRenderingContext($context); $parsedTemplate = $templateParser->getOrParseAndStoreTemplate('fake-foo-baz', function ($a, $b) { return 'test'; }); }