Esempio n. 1
0
 public function testReset()
 {
     $queue = new ActionQueue();
     $counter = 0;
     $queue->addAction(function () use(&$counter) {
         $counter++;
         return true;
     });
     $queue->reset();
     foreach ($queue as $action) {
         $this->assertTrue($action());
     }
     $this->assertSame(0, $counter);
 }
Esempio n. 2
0
 public function close()
 {
     $this->pdo = null;
     $this->actionQueue->reset();
 }
Esempio n. 3
0
 public function testActionQueueGetsCalledAfterConnect()
 {
     $actionQueue = new ActionQueue();
     $called = 0;
     $that = $this;
     // Sindri/Database don´t need PHP 5.4 - so we stay 5.3 safe
     $actionQueue->addAction(function ($pdo) use($that, &$called) {
         $that->assertTrue($pdo instanceof PDO);
         $called++;
     });
     $connection = new Connection("", "", "sqlite::memory:", array(), $actionQueue);
     $connection->run("SELECT 1;");
     $this->assertSame(1, $called);
 }
Esempio n. 4
0
 /**
  * It would be useful if you plan to use the sqlite createAggregate method (for example)
  *
  * @see http://www.php.net/manual/de/pdo.sqlitecreateaggregate.php
  *
  * @param Closure $action
  */
 public function addActionAfterConnect(Closure $action)
 {
     $this->actionQueue->addAction($action);
 }