public function testSuccessfull() { $db = (require __DIR__ . "/config.php"); $mysqltcs = new Mysqltcs($db['host'], $db['user'], $db['psw'], $db['db']); $mysqltcs2 = clone $mysqltcs; $operations = new MysqltcsOperations($mysqltcs, $db['tables']['test1']); $operations2 = clone $operations; $operations2->setMysqltcs($mysqltcs2); //commit $mysqltcs->setAutocommit(false); $operations->insert("value, value2", "'tt', 'kk'"); $this->assertEmpty($operations2->getList("*", "1")); $mysqltcs2->commit(); $this->assertEmpty($operations2->getList("*", "1")); $mysqltcs->commit(); $this->assertNotEmpty($operations2->getList("*", "1")); $mysqltcs->setAutocommit(true); $operations->deleteRows("1"); //autocommit $mysqltcs->setAutocommit(false); $operations->insert("value, value2", "'tt', 'kk'"); $this->assertEmpty($operations2->getList("*", "1")); $mysqltcs->setAutocommit(true); $this->assertNotEmpty($operations2->getList("*", "1")); $operations->deleteRows("1"); //rollback $mysqltcs->setAutocommit(false); $operations->insert("value, value2", "'tt', 'kk'"); $this->assertEmpty($operations2->getList("*", "1")); $mysqltcs->rollBack(); $this->assertEmpty($operations2->getList("*", "1")); $mysqltcs->setAutocommit(true); $this->assertEmpty($operations2->getList("*", "1")); $operations->deleteRows("1"); //this to avoid problems in other tests, in normal situations thi lines is useless }
private function simpleChain() { $db = (require __DIR__ . "/config.php"); $expected = array(); self::$connection->insert($db['tables']['test1'] . ".value", "'test1'"); $expected[] = array("id" => self::$connection->getLastId(), "value" => "test1"); self::$connection->insert($db['tables']['test1'] . ".value", "'test2'"); $id = self::$connection->getLastId(); self::$connection->update(array($db['tables']['test1'] . ".value" => "'test3'"), $db['tables']['test1'] . ".id = " . $id); $expected[] = array("id" => $id, "value" => "test3"); $this->assertEquals($expected, self::$connection->getList($db['tables']['test1'] . ".id, " . $db['tables']['test1'] . ".value", "1", "id ASC")); $this->assertNotEquals($expected, self::$connection->getList($db['tables']['test1'] . ".id, " . $db['tables']['test1'] . ".value", "1", "id DESC")); foreach ($expected as $row) { self::$connection->deleteRows($db['tables']['test1'] . ".id = " . $row['id']); } $this->assertEquals(array(), self::$connection->getList("*", "1")); }