public function test_should_simple_query_works_fine() { $mysql = new Mysql(__DIR__ . '/ini/mysql_test.ini'); try { $mysql->connectToSlave(); } catch (\Exception $e) { $this->assertContains("\tCONNECT_ERROR\t-\t{\"host\":\"127.0.0.1\",\"port\":3306,\"user\":\"user_ro\",\"pass\":\"**\",\"error\":", self::getLogContents($this->logfile, -1)); } $rs = self::$mysql->getAll(self::$mysql->query('SHOW DATABASES')); $this->assertContains("\tQUERY_OK\t-\t{\"sql\":\"SHOW DATABASES\"", self::getLogContents($this->logfile, -1)); $this->assertContains(array('Database' => 'test'), $rs); $this->assertFalse(self::$mysql->query('I AM A WRONG QUERY')); $this->assertContains("\tQUERY_ERROR\t-\t{\"sql\":\"I AM A WRONG QUERY\",\"async\":false,\"error\":", self::getLogContents($this->logfile, -1)); $this->assertEquals(1, self::$mysql->query('INSERT INTO only_for_test (content) VALUES ("aabbcc")')); $lastId = self::$mysql->lastId(); $this->assertEquals($lastId, self::$mysql->getOne(self::$mysql->query('SELECT MAX(id) FROM only_for_test'))); self::$mysql->query('INSERT INTO only_for_test (content) VALUES ("aabbcc2")'); $this->assertTrue($lastId < self::$mysql->lastId()); }