Beispiel #1
0
 /**
  * @expectedException \Sindri\Database\Exception\AlreadyConnectedException
  */
 public function testThrowsExceptionIfQueueIsLocked()
 {
     $queue = new ActionQueue();
     $queue->lock();
     $queue->addAction(function () {
         return true;
     });
 }
Beispiel #2
0
 /**
  * @throws ConnectionException
  * @return PDO|null
  */
 protected function connect()
 {
     $retVal = null;
     try {
         $retVal = new PDO($this->dsn, $this->username, $this->password, $this->options);
     } catch (PDOException $ex) {
         throw new ConnectionException("Can´t connect to database: '" . $ex->getMessage() . "'", null, $ex);
     }
     $this->actionQueue->lock();
     foreach ($this->actionQueue as $action) {
         $action($retVal);
     }
     return $retVal;
 }