Exemplo n.º 1
0
 /**
  * Verify that a transaction can be managed.
  */
 public function testManageATransactionState()
 {
     $this->manager->begin();
     $this->manager->commit();
     $this->manager->begin();
     $this->manager->rollback();
 }
Exemplo n.º 2
0
Arquivo: Sqon.php Projeto: sqon/sqon
 /**
  * {@inheritdoc}
  */
 public function setPathsUsingIterator(Iterator $iterator)
 {
     $this->dispatch(BeforeSetPathsUsingIteratorEvent::NAME, BeforeSetPathsUsingIteratorEvent::class, function (BeforeSetPathsUsingIteratorEvent $event) use(&$iterator) {
         $iterator = $event->getIterator();
     }, $iterator);
     $this->database->begin();
     try {
         foreach ($iterator as $path => $manager) {
             if (!is_string($path)) {
                 // @codeCoverageIgnoreStart
                 throw new SqonException('The key returned by the iterator must be the path.');
                 // @codeCoverageIgnoreEnd
             }
             if (!$manager instanceof PathInterface) {
                 // @codeCoverageIgnoreStart
                 throw new SqonException('The value returned by the iterator must be a path manager.');
                 // @codeCoverageIgnoreEnd
             }
             $this->setPath($this->cleanPath($path), $manager);
         }
         // @codeCoverageIgnoreStart
     } catch (Exception $exception) {
         $this->database->rollback();
         throw $exception;
     }
     // @codeCoverageIgnoreEnd
     $this->database->commit();
     $this->dispatch(AfterSetPathsUsingIteratorEvent::NAME, AfterSetPathsUsingIteratorEvent::class, null, $iterator);
     return $this;
 }