Beispiel #1
0
 /**
  * test the whole process
  *
  * @return void
  */
 public function testProcess()
 {
     $this->cacheUtils->invalidate('de', 'hans');
     $this->cacheUtils->invalidate('fr', 'franz');
     // we did invalidations.. resources files shall not be here yet! (test lazyness)
     $this->assertFileNotExists($this->resourceDir . 'hans.de.odm');
     $this->assertFileNotExists($this->resourceDir . 'franz.fr.odm');
     $this->cacheUtils->processPending();
     $resources = ['de' => ['/hans.po']];
     $finalResources = $this->cacheUtils->getResources($resources);
     // see if our final resource is in the cache
     $this->assertEquals($finalResources, $this->cacheUtils->getCache()->fetch('i18n.finalResources'));
     // see if our files are in the arrays
     $this->assertEquals('/hans.po', $finalResources['de'][0]);
     $this->assertEquals($this->resourceDir . 'hans.de.odm', $finalResources['de'][1]);
     $this->assertEquals($this->resourceDir . 'franz.fr.odm', $finalResources['fr'][0]);
     // ok, now the files *need* to exist..
     $this->assertFileExists($this->resourceDir . 'hans.de.odm');
     $this->assertFileExists($this->resourceDir . 'franz.fr.odm');
     // now, invalidate something more
     $this->cacheUtils->invalidate('de', 'trudi');
     // process
     $this->cacheUtils->processPending();
     $finalResources = $this->cacheUtils->getResources($resources);
     // again put in cache?
     $this->assertEquals($finalResources, $this->cacheUtils->getCache()->fetch('i18n.finalResources'));
     // file exists?
     $this->assertFileExists($this->resourceDir . 'trudi.de.odm');
     // new item in map?
     $this->assertEquals($this->resourceDir . 'trudi.de.odm', $finalResources['de'][2]);
 }
 /**
  * hooked to the 'kernel.terminate' event - persists changes in the cache utils
  *
  * @param Event $event event
  *
  * @return void
  */
 public function onTerminate(Event $event)
 {
     $this->cacheUtils->processPending();
 }