/** * @covers PDOK\Connector::disconnect */ public function testDisconnect() { $c = new Connector('sqlite::memory:'); $c->query("SELECT 1"); $this->assertNotNull($this->getProtected($c, 'pdo')); $c->disconnect(); $this->assertNull($this->getProtected($c, 'pdo')); }
/** * @covers PDOK\Connector::query() * @covers PDOK\Connector::prepare() */ function testCustomStatementReturn() { $statementClass = __NAMESPACE__ . '\\ConnectorStatementTestStatement'; $connector = new \PDOK\Connector('sqlite::memory:'); $connector->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array($statementClass)); $connector->exec("CREATE TABLE foo(id INTEGER);"); $stmt = $connector->prepare('SELECT * FROM foo'); $this->assertInstanceOf('PDOK\\StatementWrapper', $stmt); $this->assertInstanceOf($statementClass, $stmt->statement); $stmt = $connector->query('SELECT * FROM foo'); $this->assertInstanceOf('PDOK\\StatementWrapper', $stmt); $this->assertInstanceOf($statementClass, $stmt->statement); }
/** * @covers PDOK\Connector::execAll * @covers PDOK\Connector::executeAll */ public function testExecuteAll() { $conn = new \PDOK\Connector('sqlite::memory:'); $conn->executeAll(array("CREATE TABLE foo(id INT, val STRING);", "INSERT INTO foo(id, val) VALUES(3, 'yep');")); $rows = $conn->query("SELECT * FROM foo")->fetchAll(\PDO::FETCH_ASSOC); $this->assertEquals(array(array('id' => 3, 'val' => 'yep')), $rows); }