public function testToString() { $db = (require __DIR__ . "/config.php"); $connection = new Mysqltcs($db['host'], $db['user'], $db['psw'], $db['db']); $operations = new MysqltcsOperations($connection, $db['tables']['test1'], true); $expected = "from: " . $db['tables']['test1'] . "\nquotes: true\nmysqltcs:\n" . "instance number: " . $connection->getInstanceNumber() . "\nhost: " . $db['host'] . "\nuser: "******"\npassword: "******"\nname: " . $db['db'] . "\nkey: " . "" . "\ncert: " . "" . "\nca: " . "\nnew conenction: " . "true" . "\nconnection thread id: " . $connection->getConnectionThreadId(); $this->assertEquals((string) $operations, $expected); }
public function testLoggerPrint() { $logger = new SimpleLogger(); $this->connection->setLogger($logger); $this->assertFalse($logger->isPrint()); $logger->setPrint(true); $this->assertTrue($logger->isPrint()); $this->expectOutputString("show tables\n"); $this->connection->executeQuery("show tables"); $logger->setPrint(false); $this->assertFalse($logger->isPrint()); }
public function testLogger() { $db = (require __DIR__ . "/config.php"); $mysqltcs = new Mysqltcs($db['host'], $db['user'], $db['psw'], $db['db']); $mysqltcs->setSimpleLogger(); $mysqltcs->setAutocommit(false); $logA = $mysqltcs->getLogger()->getLogArray(); $this->assertEquals("autocommit set to false", $logA[count($logA) - 1]); $mysqltcs->commit(); $logA = $mysqltcs->getLogger()->getLogArray(); $this->assertEquals("commit", $logA[count($logA) - 1]); $mysqltcs->rollBack(); $logA = $mysqltcs->getLogger()->getLogArray(); $this->assertEquals("rollback", $logA[count($logA) - 1]); }
/** * return the escaped string * @param $string * @return string */ public function getEscapedString($string) { return $this->mysqltcs->getEscapedString($string); }