ILIAS  release_7 Revision v7.30-3-g800a261c036
ilDatabaseAtomBaseTest Class Reference

TestCase for the ilDatabaseAtomBaseTest. More...

+ Inheritance diagram for ilDatabaseAtomBaseTest:
+ Collaboration diagram for ilDatabaseAtomBaseTest:

Public Member Functions

 testGetInstance ()
 
 testReadUncommited ()
 
 testReadCommited ()
 
 testReadRepeatedRead ()
 
 testAnomalies ()
 
 testLevel ()
 
 testRisks ()
 
 testCallables ()
 
 testWrongIsolationLevel ()
 
 testQueryWithFiveException ()
 
 testQueryWithTenException ()
 
 testWithOutLocks ()
 
 testWithOutClosures ()
 
 testMultipleClosures ()
 
 testLockSameTable ()
 
 testLockSameTableWithAlias ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $backupGlobals = false
 
 $ilDBInterfaceGalera
 
 $ilDBInterfaceInnoDB
 

Detailed Description

TestCase for the ilDatabaseAtomBaseTest.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

@group needsInstalledILIAS

@runInSeparateProcess @preserveGlobalState disabled @backupGlobals disabled @backupStaticAttributes disabled

Definition at line 39 of file ilDatabaseAtomBaseTest.php.

Member Function Documentation

◆ setUp()

ilDatabaseAtomBaseTest::setUp ( )
protected

Definition at line 56 of file ilDatabaseAtomBaseTest.php.

56 : void
57 {
58 ilUnitUtil::performInitialisation();
59
60 global $ilClientIniFile;
62 $this->ilDBInterfaceGalera->initFromIniFile($ilClientIniFile);
63 $this->ilDBInterfaceGalera->connect();
64
66 $this->ilDBInterfaceInnoDB->initFromIniFile($ilClientIniFile);
67 $this->ilDBInterfaceInnoDB->connect();
68 }

References ilDBWrapperFactory\getWrapper(), ilDBConstants\TYPE_GALERA, and ilDBConstants\TYPE_PDO_MYSQL_INNODB.

+ Here is the call graph for this function:

◆ testAnomalies()

ilDatabaseAtomBaseTest::testAnomalies ( )

Definition at line 107 of file ilDatabaseAtomBaseTest.php.

108 {
109 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ANO_NOT_AVAILABLE);
111 }
static checkAnomaly($anomalie)

References ilAtomQueryBase\checkAnomaly(), and ilAtomQueryException\DB_ATOM_ANO_NOT_AVAILABLE.

+ Here is the call graph for this function:

◆ testCallables()

ilDatabaseAtomBaseTest::testCallables ( )

Definition at line 129 of file ilDatabaseAtomBaseTest.php.

130 {
131 $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
132 // Working
133 $this->assertTrue($ilAtomQuery->checkCallable(function (ilDBInterface $ilDBInterface) {
134 })); // ilDBInterface as first Parameter
135 $this->assertTrue($ilAtomQuery->checkCallable(new ilAtomQueryTestHelper())); // Class with implemented __invoke
136
137 // Non working
138 $this->assertFalse($ilAtomQuery->checkCallable(function () {
139 })); // No Parameter
140 $this->assertFalse($ilAtomQuery->checkCallable(function (ilDBInterface $ilDBInterface, $someOtherParameter) {
141 })); // More than one parameter
142 $this->assertFalse($ilAtomQuery->checkCallable(function ($someOtherParameter, ilDBInterface $ilDBInterface) {
143 })); // ilDBInterface not first parameter
144 $this->assertFalse($ilAtomQuery->checkCallable(function (ilDBPdoMySQL $ilDBInterface) {
145 })); // not ilDBInterface
146 $this->assertFalse($ilAtomQuery->checkCallable(function ($ilDBInterface) {
147 })); // not ilDBInterface
148 function noClosure()
149 {
150 }
151
152 $this->assertFalse($ilAtomQuery->checkCallable('noClosure')); // Not a Closure
153 }
Class ilAtomQueryTestHelper.
Class ilDBPdoMySQL.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ testGetInstance()

ilDatabaseAtomBaseTest::testGetInstance ( )

Definition at line 71 of file ilDatabaseAtomBaseTest.php.

72 {
73 $ilAtomQueryTransaction = $this->ilDBInterfaceGalera->buildAtomQuery();
74 $this->assertEquals($ilAtomQueryTransaction->getIsolationLevel(), ilAtomQuery::ISOLATION_SERIALIZABLE);
75 $this->assertTrue($ilAtomQueryTransaction instanceof ilAtomQueryTransaction);
76
77 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
78 $this->assertEquals($ilAtomQuery->getIsolationLevel(), ilAtomQuery::ISOLATION_SERIALIZABLE);
79 $this->assertTrue($ilAtomQuery instanceof ilAtomQueryLock);
80 }
Class ilAtomQueryLock.
Class ilAtomQueryTransaction.

References ilAtomQuery\ISOLATION_SERIALIZABLE.

◆ testLevel()

ilDatabaseAtomBaseTest::testLevel ( )

Definition at line 114 of file ilDatabaseAtomBaseTest.php.

115 {
116 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ISO_WRONG_LEVEL);
118 }
static checkIsolationLevel($isolation_level)

References ilAtomQueryBase\checkIsolationLevel(), and ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL.

+ Here is the call graph for this function:

◆ testLockSameTable()

ilDatabaseAtomBaseTest::testLockSameTable ( )

Definition at line 242 of file ilDatabaseAtomBaseTest.php.

243 {
244 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_IDENTICAL_TABLES);
245 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
246 $ilAtomQuery->addTableLock('il_db_tests_atom');
247 $ilAtomQuery->addTableLock('il_db_tests_atom');
248 $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) {
249 });
250 $ilAtomQuery->run();
251 }

References ilAtomQueryException\DB_ATOM_IDENTICAL_TABLES.

◆ testLockSameTableWithAlias()

ilDatabaseAtomBaseTest::testLockSameTableWithAlias ( )

Definition at line 254 of file ilDatabaseAtomBaseTest.php.

255 {
256 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_IDENTICAL_TABLES);
257 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
258 $ilAtomQuery->addTableLock('il_db_tests_atom')->aliasName('alias_one');
259 $ilAtomQuery->addTableLock('il_db_tests_atom')->aliasName('alias_one');
260 $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) {
261 });
262 $ilAtomQuery->run();
263 }

References ilAtomQueryException\DB_ATOM_IDENTICAL_TABLES.

◆ testMultipleClosures()

ilDatabaseAtomBaseTest::testMultipleClosures ( )

Definition at line 230 of file ilDatabaseAtomBaseTest.php.

231 {
232 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_CLOSURE_ALREADY_SET);
233 $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
234 $ilAtomQuery->addTableLock('object_data');
235 $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) {
236 });
237 $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) {
238 });
239 }

References ilAtomQueryException\DB_ATOM_CLOSURE_ALREADY_SET.

◆ testQueryWithFiveException()

ilDatabaseAtomBaseTest::testQueryWithFiveException ( )

Definition at line 168 of file ilDatabaseAtomBaseTest.php.

169 {
170 $counter = 0;
171 $max = 5;
172 $result = null;
173 $query = function (ilDBInterface $ilDBInterface) use (&$counter, &$max, &$result) {
174 if ($counter < $max) {
175 $counter++;
177 }
178 $result = $ilDBInterface->listTables();
179 };
180
181 $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
182 $ilAtomQuery->addQueryCallable($query);
183 $ilAtomQuery->addTableLock('object_data');
184 $ilAtomQuery->run();
185 $this->assertTrue(is_array($result));
186 }
$result
Class ilDatabaseException.
$query

References $query, $result, and ilDatabaseException\DB_GENERAL.

◆ testQueryWithTenException()

ilDatabaseAtomBaseTest::testQueryWithTenException ( )

Definition at line 189 of file ilDatabaseAtomBaseTest.php.

190 {
191 $this->setExpectedException('ilDatabaseException', ilDatabaseException::DB_GENERAL);
192 $counter = 0;
193 $max = 10;
194 $result = null;
195 $query = function (ilDBInterface $ilDBInterface) use (&$counter, &$max, &$result) {
196 if ($counter < $max) {
197 $counter++;
199 }
200 $result = $ilDBInterface->listTables();
201 };
202
203 $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
204 $ilAtomQuery->addQueryCallable($query);
205 $ilAtomQuery->addTableLock('object_data');
206
207 $ilAtomQuery->run();
208
209 $this->assertTrue(is_null($result));
210 }

References $query, $result, and ilDatabaseException\DB_GENERAL.

◆ testReadCommited()

ilDatabaseAtomBaseTest::testReadCommited ( )

Definition at line 91 of file ilDatabaseAtomBaseTest.php.

92 {
93 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ISO_WRONG_LEVEL);
94 $other = new ilAtomQueryTransaction($this->ilDBInterfaceGalera, ilAtomQuery::ISOLATION_READ_COMMITED);
95 $other->run();
96 }

References ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL, and ilAtomQuery\ISOLATION_READ_COMMITED.

◆ testReadRepeatedRead()

ilDatabaseAtomBaseTest::testReadRepeatedRead ( )

Definition at line 99 of file ilDatabaseAtomBaseTest.php.

100 {
101 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ISO_WRONG_LEVEL);
102 $other = new ilAtomQueryTransaction($this->ilDBInterfaceGalera, ilAtomQuery::ISOLATION_REPEATED_READ);
103 $other->run();
104 }

References ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL, and ilAtomQuery\ISOLATION_REPEATED_READ.

◆ testReadUncommited()

ilDatabaseAtomBaseTest::testReadUncommited ( )

Definition at line 83 of file ilDatabaseAtomBaseTest.php.

84 {
85 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ISO_WRONG_LEVEL);
86 $other = new ilAtomQueryTransaction($this->ilDBInterfaceGalera, ilAtomQuery::ISOLATION_READ_UNCOMMITED);
87 $other->run();
88 }

References ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL, and ilAtomQuery\ISOLATION_READ_UNCOMMITED.

◆ testRisks()

ilDatabaseAtomBaseTest::testRisks ( )

Definition at line 121 of file ilDatabaseAtomBaseTest.php.

122 {
123 $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
124 $ilAtomQuery->addTableLock('object_data');
125 $this->assertEquals(array(), $ilAtomQuery->getRisks());
126 }

◆ testWithOutClosures()

ilDatabaseAtomBaseTest::testWithOutClosures ( )

Definition at line 221 of file ilDatabaseAtomBaseTest.php.

222 {
223 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_CLOSURE_NONE);
224 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
225 $ilAtomQuery->addTableLock('object_data');
226 $ilAtomQuery->run();
227 }

References ilAtomQueryException\DB_ATOM_CLOSURE_NONE.

◆ testWithOutLocks()

ilDatabaseAtomBaseTest::testWithOutLocks ( )

Definition at line 213 of file ilDatabaseAtomBaseTest.php.

214 {
215 $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_LOCK_NO_TABLE);
216 $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
217 $ilAtomQuery->run();
218 }

References ilAtomQueryException\DB_ATOM_LOCK_NO_TABLE.

◆ testWrongIsolationLevel()

ilDatabaseAtomBaseTest::testWrongIsolationLevel ( )

Definition at line 156 of file ilDatabaseAtomBaseTest.php.

157 {
158 $this->setExpectedException('ilDatabaseException');
159 $ilAtomQuery = new ilAtomQueryTransaction($this->ilDBInterfaceGalera, 'non_existing');
160 $ilAtomQuery->addTableLock('il_db_tests_atom');
161 $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) {
162 $ilDB->getDBType();
163 });
164 $ilAtomQuery->run();
165 }
global $ilDB

References $ilDB.

Field Documentation

◆ $backupGlobals

ilDatabaseAtomBaseTest::$backupGlobals = false
protected

Definition at line 45 of file ilDatabaseAtomBaseTest.php.

◆ $ilDBInterfaceGalera

ilDatabaseAtomBaseTest::$ilDBInterfaceGalera
protected

Definition at line 49 of file ilDatabaseAtomBaseTest.php.

◆ $ilDBInterfaceInnoDB

ilDatabaseAtomBaseTest::$ilDBInterfaceInnoDB
protected

Definition at line 53 of file ilDatabaseAtomBaseTest.php.


The documentation for this class was generated from the following file: