Пример #1
0
 private function purgeForTheFirstTime()
 {
     $this->entityManager->getConnection()->getConfiguration()->setSQLLogger($this->queryLogger);
     $this->purger->purge();
     $this->cachedQueries = $this->queryLogger->getLoggedQueries();
     $this->queryLogger->clearLoggedQueries();
 }
Пример #2
0
 function it_executes_cached_queries_after_the_first_purging(PurgerInterface $purger, EntityManagerInterface $entityManager, QueryLoggerInterface $queryLogger, Connection $connection, Configuration $configuration)
 {
     $entityManager->getConnection()->willReturn($connection);
     $connection->getConfiguration()->willReturn($configuration);
     $configuration->setSQLLogger($queryLogger)->shouldBeCalled();
     $purger->purge()->shouldBeCalled();
     $queryLogger->getLoggedQueries()->willReturn([['sql' => 'SQL QUERY', 'params' => [], 'types' => []]]);
     $queryLogger->clearLoggedQueries()->shouldBeCalled();
     $this->purge();
     $configuration->setSQLLogger(null)->shouldBeCalled();
     $connection->executeUpdate('SQL QUERY', [], [])->shouldBeCalled();
     $this->purge();
 }
Пример #3
0
 /**
  * @BeforeScenario
  */
 public function purgeDatabase(BeforeScenarioScope $scope)
 {
     $entityManager = $this->getService('doctrine.orm.entity_manager');
     $entityManager->getConnection()->getConfiguration()->setSQLLogger(null);
     $isMySqlDriver = $entityManager->getConnection()->getDriver() instanceof PDOMySqlDriver;
     if ($isMySqlDriver) {
         $entityManager->getConnection()->executeUpdate("SET foreign_key_checks = 0;");
     }
     if (null === self::$ormPurger) {
         self::$ormPurger = $this->getService('sylius.purger.orm_purger');
     }
     self::$ormPurger->purge();
     if ($isMySqlDriver) {
         $entityManager->getConnection()->executeUpdate("SET foreign_key_checks = 1;");
     }
     $entityManager->clear();
 }