/** * @covers phpDocumentor\Transformer\Template\Factory::get * @covers phpDocumentor\Transformer\Template\Factory::fetchTemplateXmlFromPath * @covers phpDocumentor\Transformer\Template\Factory::createTemplateFromXml */ public function testRetrieveInstantiatedTemplate() { // Arrange $templateName = 'clean'; $template = new Template($templateName); vfsStream::setup('exampleDir')->addChild(vfsStream::newFile('template.xml')->setContent('xml')); $this->pathResolverMock->shouldReceive('resolve')->with($templateName)->andReturn(vfsStream::url('exampleDir')); $this->serializerMock->shouldReceive('deserialize')->with('xml', 'phpDocumentor\\Transformer\\Template', 'xml')->andReturn($template); // Act $result = $this->fixture->get($templateName); // Assert $this->assertSame($template, $result); }
/** * Loads a template with the given name or file path. * * @param string $nameOrPath * * @return void */ public function load($nameOrPath) { $template = $this->factory->get($nameOrPath); /** @var Transformation $transformation */ foreach ($template as $transformation) { /** @var WriterAbstract $writer */ $writer = $this->writerCollection[$transformation->getWriter()]; if ($writer) { $writer->checkRequirements(); } } $this[$template->getName()] = $template; }