Пример #1
0
 /**
  * On Request received check the validity of the webpack cache.
  *
  * @param GetResponseEvent $event the response to send to te browser, we don't we only ensure the cache is there.
  */
 public function onRequest(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $this->guard->rebuild();
 }
Пример #2
0
 /**
  * Simple test for the case the cache is not outdated.
  */
 public function testCacheUpToDate()
 {
     $compiler = $this->prophesize(Compiler::class);
     $compiler->compile()->willReturn('some debug output')->shouldNotBeCalled();
     $dumper = $this->prophesize(Dumper::class);
     $dumper->dump()->shouldNotBeCalled();
     //Cache is not outdated
     $tracker = $this->prophesize(Tracker::class);
     $tracker->isOutdated()->willReturn(false);
     //What do we expect for logging
     $logger = $this->prophesize(LoggerInterface::class);
     $logger->info('[Webpack]: Cache still up-to-date.')->shouldBeCalled();
     $cache_guard = new CacheGuard($compiler->reveal(), $dumper->reveal(), $tracker->reveal(), $logger->reveal());
     $cache_guard->rebuild();
 }
Пример #3
0
 /**
  * Execute the webpack:compile command (basicly forwards the logic to CacheGuard::validate).
  *
  * {@inheritDoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->guard->rebuild();
 }
 public function testRequestMasterRequest()
 {
     $this->guard->expects($this->once())->method('rebuild');
     $this->event->expects($this->once())->method('isMasterRequest')->willReturn(true);
     (new RequestListener($this->guard))->onRequest($this->event);
 }
 /**
  * {@inheritdoc}
  */
 public function warmUp($cache_dir)
 {
     $this->guard->rebuild();
 }