protected function execute(InputInterface $input, OutputInterface $output) { $baseDir = dirname(dirname(__FILE__)); $loader = new \Twig_Loader_Filesystem($baseDir . '/../app/Resources/templates/'); $twig = new \Twig_Environment($loader); $baseDirAdapter = new Local($baseDir . '/../'); $genericFS = new Filesystem($baseDirAdapter); $sectionRepository = new SectionRepository($genericFS); $pres = new PresentationRepository($genericFS, $sectionRepository); $adapter = new Local($baseDir . '/../web'); $filesystem = new Filesystem($adapter); $filesystem->put('index.html', $twig->render('basic.html.twig', ['pres' => $pres->get()])); $output->writeln('Success'); }
public function testGetPresentation() { $filesystem = $this->prophesize('League\\Flysystem\\Filesystem'); $testYml = "presentation:\n title: 'Test'\n sections:\n - chapter1"; $filesystem->read(Argument::any())->willReturn($testYml)->shouldBeCalled(); $sectionRepo = $this->prophesize('Msg\\Repository\\SectionRepository'); $section = new Section(); $section->setTitle('test sec'); $sectionRepo->get(Argument::any())->willReturn($section)->shouldBeCalled(); $repo = new PresentationRepository($filesystem->reveal(), $sectionRepo->reveal()); $pres = $repo->get(); $this->assertInstanceOf('Msg\\Model\\Presentation', $pres); $this->assertEquals('Test', $pres->getTitle()); $this->assertInstanceOf('ArrayObject', $pres->getSections()); $this->assertEquals($section, $pres->getSections()->offsetGet(0)); }