assertTrue($pdo->connect()); } public function testCreateTable() { global $pdo; $sql_table="DROP TABLE IF EXISTS table_test; CREATE TABLE table_test ( `name` VARCHAR(255) NOT NULL default '', `last_name` VARCHAR(255) NOT NULL default '', `type` INT NOT NULL );"; $this->assertTrue($pdo->query($sql_table, [])); } /** * @depends testCreateTable */ public function testInsert() { global $pdo; $this->assertEquals('table_test', $pdo->table->name); $this->assertTrue($pdo->insert(['name', 'last_name', 'type'], ['first', 'last', '1'])); } /** * @depends testInsert */ public function testSelect() { global $pdo; $this->assertEquals('table_test', $pdo->table->name); $this->assertTrue($pdo->select(['name'], 'WHERE name=? AND type=?', ['first', 1])); $arr_result=$pdo->sth->fetchAll(); $this->assertEquals([['name' => 'first', 0 => 'first']], $arr_result); $this->assertEquals([['name' => 'first', 0 => 'first']], $pdo->select_to_array(['name'], 'WHERE name=? AND type=?', ['first', 1])); $this->assertEquals(['name' => 'first', 0 => 'first'], $pdo->select_a_row(['name'], 'WHERE name=? AND type=?', ['first', 1])); $this->assertEquals(1, $pdo->select_count('WHERE name=?', ['first'])); } /** * @depends testCreateTable */ public function testDropTable() { global $pdo; $this->assertTrue($pdo->query('drop table table_test', [])); } }