59 require_once(
"./Services/PHPUnit/classes/class.ilUnitUtil.php");
60 ilUnitUtil::performInitialisation();
62 global $ilClientIniFile;
64 $this->ilDBInterfaceGalera->initFromIniFile($ilClientIniFile);
65 $this->ilDBInterfaceGalera->connect();
68 $this->ilDBInterfaceGaleraSecond->initFromIniFile($ilClientIniFile);
69 $this->ilDBInterfaceGaleraSecond->connect();
72 $this->ilDBInterfaceInnoDB->initFromIniFile($ilClientIniFile);
73 $this->ilDBInterfaceInnoDB->connect();
76 $this->ilDBInterfaceInnoDBSecond->initFromIniFile($ilClientIniFile);
77 $this->ilDBInterfaceInnoDBSecond->connect();
85 $this->ilDBInterfaceGalera->dropSequence(
'il_db_tests_atom');
86 $this->ilDBInterfaceGalera->dropTable(
'il_db_tests_atom');
92 $this->assertTrue($this->ilDBInterfaceGalera->connect(
true));
93 $this->assertTrue($this->ilDBInterfaceGaleraSecond->connect(
true));
94 $this->assertTrue($this->ilDBInterfaceInnoDB->connect(
true));
100 if ($this->ilDBInterfaceGalera->sequenceExists(
'il_db_tests_atom')) {
101 $this->ilDBInterfaceGalera->dropSequence(
'il_db_tests_atom');
103 $this->ilDBInterfaceGalera->createTable(
'il_db_tests_atom', $fields = array(
109 'is_online' => array(
115 $this->ilDBInterfaceGalera->addPrimaryKey(
'il_db_tests_atom', array(
'id' ));
116 $this->ilDBInterfaceGalera->createSequence(
'il_db_tests_atom');
122 $this->assertTrue($this->ilDBInterfaceGalera->tableExists(
'il_db_tests_atom'));
128 $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
129 $ilAtomQuery->addTableLock(
'il_db_tests_atom')->lockSequence(
true);
140 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
141 $ilAtomQuery->addTableLock(
'il_db_tests_atom')->lockSequence(
true);
152 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
153 $ilAtomQuery->addTableLock(
'il_db_tests_atom')->lockSequence(
true)->aliasName(
'my_alias');
164 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
165 $ilAtomQuery->addTableLock(
'il_db_tests_atom')->lockSequence(
true)->aliasName(
'my_alias');
166 $ilAtomQuery->addTableLock(
'il_db_tests_atom')->lockSequence(
true)->aliasName(
'my_second_alias');
177 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
178 $ilAtomQuery->addTableLock(
'il_db_tests_atom')->lockSequence(
true);
179 $ilAtomQuery->addTableLock(
'il_db_tests_atom')->lockSequence(
true)->aliasName(
'my_alias');
190 $this->setExpectedException(
'ilDatabaseException');
191 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
200 $this->setExpectedException(
'ilDatabaseException');
201 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
202 $ilAtomQuery->addTableLock(
'il_db_tests_atom');
210 $this->ilDBInterfaceGalera->insert(
'il_db_tests_atom', array(
211 'id' => array(
'integer', $this->ilDBInterfaceGalera->nextId(
'il_db_tests_atom') ),
212 'is_online' => array(
'integer', 1 ),
216 $this->ilDBInterfaceGalera->beginTransaction();
217 $this->ilDBInterfaceGalera->update(
'il_db_tests_atom', array(
218 'is_online' => array(
'integer', 5 ),
219 ), array(
'id' => array(
'integer', 1 ) ));
227 $this->ilDBInterfaceGalera->commit();
230 $query =
'SELECT is_online FROM il_db_tests_atom WHERE id = ' . $this->ilDBInterfaceGalera->quote(1,
'integer');
231 $res = $this->ilDBInterfaceGalera->query(
$query);
232 $d = $this->ilDBInterfaceGalera->fetchAssoc(
$res);
234 $this->assertEquals(5,
$d[
'is_online']);
240 $this->ilDBInterfaceInnoDB->insert(
'il_db_tests_atom', array(
241 'id' => array(
'integer', $this->ilDBInterfaceInnoDB->nextId(
'il_db_tests_atom') ),
242 'is_online' => array(
'integer', 1 ),
245 $this->ilDBInterfaceInnoDB->lockTables(array( array(
'name' =>
'il_db_tests_atom',
'type' =>
ilAtomQuery::LOCK_WRITE ) ));
246 $this->ilDBInterfaceInnoDB->update(
'il_db_tests_atom', array(
247 'is_online' => array(
'integer', 5 ),
248 ), array(
'id' => array(
'integer', 1 ) ));
256 $this->ilDBInterfaceInnoDB->unlockTables();
259 $query =
'SELECT is_online FROM il_db_tests_atom WHERE id = ' . $this->ilDBInterfaceInnoDB->quote(1,
'integer');
260 $res = $this->ilDBInterfaceInnoDB->query(
$query);
261 $d = $this->ilDBInterfaceInnoDB->fetchAssoc(
$res);
263 $this->assertEquals(5,
$d[
'is_online']);
278 $ilDB->insert(
'il_db_tests_atom', array(
279 'id' => array(
'integer',
$ilDB->nextId(
'il_db_tests_atom') ),
280 'is_online' => array(
'integer', 1 ),
282 $ilDB->insert(
'il_db_tests_atom', array(
283 'id' => array(
'integer',
$ilDB->nextId(
'il_db_tests_atom') ),
284 'is_online' => array(
'integer', 0 ),
299 'name' =>
'il_db_tests_atom',
314 $res = $this->ilDBInterfaceGalera->query(
'SELECT * FROM il_db_tests_atom');
316 while (
$d = $this->ilDBInterfaceGalera->fetchAssoc(
$res)) {
getTableLocksForDbInterface()
testWriteWithTransactions()
TestCase for the ilDatabaseAtomBaseTest.
$ilDBInterfaceGaleraSecond
const TYPE_PDO_MYSQL_INNODB
testWriteWithMultipleLocksAndAlias()
foreach($_POST as $key=> $value) $res
testUpdateDuringTransaction()
testWriteWithMultipleLocksWithAndWithoutAlias()
testWriteWithLocksAndAlias()
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
$ilDBInterfaceInnoDBSecond