public function testInstall() { $compiler = new Compiler(); $templateMacroset = TemplateMacroSet::install($compiler); $compilerClass = new ReflectionClass('Latte\\Compiler'); $compilerProperty = $compilerClass->getProperty('macros'); $compilerProperty->setAccessible(TRUE); $templateMacrosetClass = new ReflectionClass('Latte\\Macros\\MacroSet'); $templateMacrosetProperty = $templateMacrosetClass->getProperty('macros'); $templateMacrosetProperty->setAccessible(TRUE); $compilerMacros = $compilerProperty->getValue($compiler); $templateMacrosetMacros = $templateMacrosetProperty->getValue($templateMacroset); $this->assertArrayHasKey('template', $templateMacrosetMacros); $this->assertInstanceOf('Nedryse\\Latte\\Macros\\TemplateMacroSet', $templateMacrosetMacros['template'][0][0]); $this->assertSame('macroTemplate', $templateMacrosetMacros['template'][0][1]); $this->assertNull($templateMacrosetMacros['template'][1]); $this->assertNull($templateMacrosetMacros['template'][2]); $this->assertArrayHasKey('_', $templateMacrosetMacros); $this->assertInstanceOf('Nedryse\\Latte\\Macros\\TemplateMacroSet', $templateMacrosetMacros['_'][0][0]); $this->assertSame('macroTranslate', $templateMacrosetMacros['_'][0][1]); $this->assertInstanceOf('Nedryse\\Latte\\Macros\\TemplateMacroSet', $templateMacrosetMacros['_'][1][0]); $this->assertSame('macroTranslate', $templateMacrosetMacros['_'][0][1]); $this->assertNull($templateMacrosetMacros['_'][2]); $this->assertArrayHasKey('template', $compilerMacros); $this->assertInstanceOf('Nedryse\\Latte\\Macros\\TemplateMacroSet', $compilerMacros['template'][0]); $this->assertArrayHasKey('_', $compilerMacros); $this->assertInstanceOf('Nedryse\\Latte\\Macros\\TemplateMacroSet', $compilerMacros['_'][0]); }
/** * @dataProvider translateDataProvider */ public function testTranslate($translated, $latteTpl, $expected, $arguments) { $translatorMock = $this->getMockForAbstractClass('Nette\\Localization\\ITranslator'); $translatorMock->expects($this->any())->method('translate')->will($this->returnValue($translated)); $latte = new Latte\Engine(); $latte->addFilter('translate', array($translatorMock, 'translate')); $latte->onCompile[] = function ($engine) { Nedryse\Latte\Macros\TemplateMacroSet::install($engine->getCompiler()); }; $name = tempnam(sys_get_temp_dir(), 'name'); file_put_contents($name, $latteTpl); $this->assertSame($expected, $latte->renderToString($name, $arguments)); unlink($name); }
public function testInstall() { $compilerMock = $this->getMock('Latte\\Compiler'); $this->assertInstanceOf('Nedryse\\Latte\\Macros\\TemplateMacroSet', TemplateMacroSet::install($compilerMock)); $this->markTestSkipped('No way to test static method Nedryse\\Latte\\Macros\\TemplateMacroSet::install'); }