Esempio n. 1
0
 protected function setUp()
 {
     $db = MYSQL_DB;
     $settings = new Settings($db);
     $database = $settings->getDatabase();
     $settings->setDatabase(null);
     $this->connection = new Connection_MySQL($settings);
     $this->connection->query("DROP DATABASE IF EXISTS {$database};");
     $this->connection->query("CREATE DATABASE {$database};");
     $this->connection->query("USE {$database};");
     $settings->setDatabase($database);
     $this->connection->query("CREATE TABLE cat (\n\t\t\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\t\t\tname VARCHAR(50),\n\t\t\tcolour VARCHAR(50)\n\t\t) ENGINE=InnoDB");
     $this->connection->query("INSERT INTO cat (name, colour) VALUES (?, ?)", array("Simon's Cat", 'black'));
     $this->connection->query("INSERT INTO cat (name, colour) VALUES (?, ?)", array("Garfield", 'ginger'));
 }
Esempio n. 2
0
 public function testAffectedRows()
 {
     $db = MYSQL_DB;
     $settings = new Settings($db);
     $database = $settings->getDatabase();
     $settings->setDatabase(null);
     $this->connection = new Connection_PDO_MySQL($settings);
     $this->connection->query("DROP DATABASE IF EXISTS {$database};");
     $this->connection->query("CREATE DATABASE {$database};");
     $this->connection->query("USE {$database};");
     $settings->setDatabase($database);
     $this->connection->query("CREATE TABLE cat (\n\t\t\tid INTEGER PRIMARY KEY AUTO_INCREMENT,\n\t\t\tname VARCHAR(50),\n\t\t\tcolour VARCHAR(50)\n\t\t) ENGINE=InnoDB");
     $this->connection->query("INSERT INTO cat VALUES(1, 'Theta', 'red')");
     $this->assertEquals(1, $this->connection->getAffectedRows());
     $this->connection->query("UPDATE cat SET colour = ? WHERE id = ?", array('pink', 1));
     $this->assertEquals(1, $this->connection->getAffectedRows());
     $this->connection->query("UPDATE cat SET colour = ? WHERE id = ?", array('pink', 1));
     $this->assertEquals(1, $this->connection->getAffectedRows());
 }
Esempio n. 3
0
 public function testClearPassword()
 {
     $password = '******';
     $settings = new Settings("mysql://*****:*****@localhost/db");
     $this->assertEquals($settings->getPassword(), $password);
     $settings->clearPassword();
     $this->assertNotEquals($settings->getPassword(), $password);
 }