Author: Harold Iedema (hiedema@hostnet.nl)
Exemplo n.º 1
0
 /**
  * @expectedException \Symfony\Component\Filesystem\Exception\FileNotFoundException
  * @expectedExceptionMessage File "/i/dont/exist" could not be found.
  */
 public function testAddInvalidPath()
 {
     $profiler = new Profiler();
     $finder = $this->getMock(TemplateFinderInterface::class);
     $fixture_path = realpath(__DIR__ . '/../../Fixture');
     $tracker = new Tracker($profiler, $finder, $fixture_path . '/cache', $fixture_path, []);
     $tracker->addPath("/i/dont/exist");
 }
Exemplo n.º 2
0
 public function testRequestCompile()
 {
     $this->tracker->expects($this->once())->method('isOutdated')->willReturn(true);
     $this->compiler->expects($this->once())->method('compile');
     $this->dumper->expects($this->once())->method('dump');
     $this->event->expects($this->once())->method('isMasterRequest')->willReturn(true);
     (new RequestListener($this->tracker, $this->compiler, $this->dumper))->onRequest($this->event);
 }
Exemplo n.º 3
0
 /**
  * @param GetResponseEvent $event
  */
 public function onRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     if ($this->tracker->isOutdated()) {
         $this->compiler->compile();
     }
     $this->dumper->dump(new Filesystem());
 }
Exemplo n.º 4
0
 /**
  * Rebuild the cache, check to see if it's still valid and rebuild if it's outdated.
  */
 public function rebuild()
 {
     if ($this->tracker->isOutdated()) {
         $this->logger->info('[Webpack 1/2]: Compiling assets.');
         $output = $this->compiler->compile();
         $this->logger->debug($output);
         $this->logger->info('[Webpack 2/2]: Dumping assets.');
         $this->dumper->dump();
     } else {
         $this->logger->info('[Webpack]: Cache still up-to-date.');
     }
 }
Exemplo n.º 5
0
 /**
  * Add split points to the 'entry' section of the configuration.
  */
 private function addSplitPoints()
 {
     $split_points = [];
     foreach ($this->tracker->getTemplates() as $template_file) {
         $split_points = array_merge($split_points, $this->twig_parser->findSplitPoints($template_file));
     }
     foreach ($split_points as $id => $file) {
         $this->generator->addBlock((new CodeBlock())->set(CodeBlock::ENTRY, [self::getAliasId($id) => $file]));
     }
 }
Exemplo n.º 6
0
 /**
  * Test addPath for invalid path.
  *
  * @expectedException \Symfony\Component\Filesystem\Exception\FileNotFoundException
  * @expectedExceptionMessage File "/i/dont/exist" could not be found.
  */
 public function testAddInvalidPath()
 {
     $profiler = new Profiler();
     $finder = $this->getMockBuilder(TemplateFinderInterface::class)->getMock();
     $tracker = new Tracker($profiler, $finder, $this->root_dir, $this->asset_dir, $this->output_dir, []);
     $tracker->addPath("/i/dont/exist");
 }