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); }
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); }
/** * 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); }