Пример #1
0
 public function onInstallApp()
 {
     // update param
     $this->manipulator->set('anime_db.catalog.installed', true);
     $this->cache_clearer->clear();
     // prepare labels
     foreach ($this->labels as $key => $label) {
         $this->labels[$key] = $this->translator->trans($label);
     }
     // remove exists labels
     /* @var $labels Label[] */
     $labels = $this->em->getRepository('AnimeDbCatalogBundle:Label')->findBy(['name' => $this->labels]);
     foreach ($labels as $label) {
         $i = array_search($label->getName(), $this->labels);
         if ($i !== false) {
             unset($this->labels[$i]);
         }
     }
     unset($labels);
     // install new labels
     foreach ($this->labels as $label) {
         $this->em->persist((new Label())->setName($label));
     }
     $this->em->flush();
 }
Пример #2
0
 /**
  * @dataProvider getParameters
  *
  * @param string $method
  * @param string $event
  * @param array $expected
  */
 public function testOnInstalledConfigureShmop($method, $event, array $expected)
 {
     $package = $this->getMockBuilder('\\Composer\\Package\\Package')->disableOriginalConstructor()->getMock();
     $package->expects($this->once())->method('getName')->will($this->returnValue(Package::PACKAGE_SHMOP));
     $event = $this->getMockBuilder($event)->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('getPackage')->will($this->returnValue($package));
     $index = 0;
     foreach ($expected as $key => $value) {
         $this->parameters->expects($this->at($index))->method('set')->with($key, $value);
         ++$index;
     }
     // test
     call_user_func([$this->listener, $method], $event);
 }
Пример #3
0
 /**
  * @dataProvider getDataForGet
  *
  * @param string $key
  * @param string $value
  * @param array $before
  */
 public function testGet($key, $value, array $before)
 {
     file_put_contents($this->filename, Yaml::dump($before));
     $this->assertEquals($value, $this->manipulator->get($key));
 }
Пример #4
0
 /**
  * Restore config on removed shmop.
  *
  * @param RemovedEvent $event
  */
 public function onRemovedShmop(RemovedEvent $event)
 {
     if ($event->getPackage()->getName() == self::PACKAGE_SHMOP) {
         $this->parameters->set('cache_time_keeper.driver', 'cache_time_keeper.driver.file');
     }
 }