ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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

needsInstalledILIAS

disabled disabled disabled

Definition at line 37 of file ilDatabaseAtomBaseTest.php.

Member Function Documentation

◆ setUp()

ilDatabaseAtomBaseTest::setUp ( )
protected

Definition at line 54 of file ilDatabaseAtomBaseTest.php.

References ilDBConstants\TYPE_GALERA, and ilDBConstants\TYPE_PDO_MYSQL_INNODB.

55  {
56  require_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
57  ilUnitUtil::performInitialisation();
58  require_once('./Services/Database/classes/Atom/class.ilAtomQueryBase.php');
59  require_once('./Services/Database/classes/Atom/class.ilAtomQueryTransaction.php');
60  require_once('./Services/Database/classes/Atom/class.ilAtomQueryLock.php');
61  require_once('./Services/Database/classes/class.ilDBWrapperFactory.php');
62 
63  global $ilClientIniFile;
64  $this->ilDBInterfaceGalera = ilDBWrapperFactory::getWrapper(ilDBConstants::TYPE_GALERA);
65  $this->ilDBInterfaceGalera->initFromIniFile($ilClientIniFile);
66  $this->ilDBInterfaceGalera->connect();
67 
68  $this->ilDBInterfaceInnoDB = ilDBWrapperFactory::getWrapper(ilDBConstants::TYPE_PDO_MYSQL_INNODB);
69  $this->ilDBInterfaceInnoDB->initFromIniFile($ilClientIniFile);
70  $this->ilDBInterfaceInnoDB->connect();
71  }

◆ testAnomalies()

ilDatabaseAtomBaseTest::testAnomalies ( )

Definition at line 110 of file ilDatabaseAtomBaseTest.php.

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

111  {
112  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ANO_NOT_AVAILABLE);
114  }
static checkAnomaly($anomalie)
+ Here is the call graph for this function:

◆ testCallables()

ilDatabaseAtomBaseTest::testCallables ( )

Definition at line 132 of file ilDatabaseAtomBaseTest.php.

133  {
134  require_once('./Services/Database/classes/PDO/class.ilDBPdoMySQL.php');
135  require_once('./Services/Database/test/Atom/data/class.ilAtomQueryTestHelper.php');
136 
137  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
138  // Working
139  $this->assertTrue($ilAtomQuery->checkCallable(function (ilDBInterface $ilDBInterface) {
140  })); // ilDBInterface as first Parameter
141  $this->assertTrue($ilAtomQuery->checkCallable(new ilAtomQueryTestHelper())); // Class with implemented __invoke
142 
143  // Non working
144  $this->assertFalse($ilAtomQuery->checkCallable(function () {
145  })); // No Parameter
146  $this->assertFalse($ilAtomQuery->checkCallable(function (ilDBInterface $ilDBInterface, $someOtherParameter) {
147  })); // More than one parameter
148  $this->assertFalse($ilAtomQuery->checkCallable(function ($someOtherParameter, ilDBInterface $ilDBInterface) {
149  })); // ilDBInterface not first parameter
150  $this->assertFalse($ilAtomQuery->checkCallable(function (ilDBPdoMySQL $ilDBInterface) {
151  })); // not ilDBInterface
152  $this->assertFalse($ilAtomQuery->checkCallable(function ($ilDBInterface) {
153  })); // not ilDBInterface
154  function noClosure()
155  {
156  }
157 
158  $this->assertFalse($ilAtomQuery->checkCallable('noClosure')); // Not a Closure
159  }
Class ilDBPdoMySQL.
Class ilAtomQueryTestHelper.

◆ testGetInstance()

ilDatabaseAtomBaseTest::testGetInstance ( )

Definition at line 74 of file ilDatabaseAtomBaseTest.php.

References ilAtomQuery\ISOLATION_SERIALIZABLE.

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

◆ testLevel()

ilDatabaseAtomBaseTest::testLevel ( )

Definition at line 117 of file ilDatabaseAtomBaseTest.php.

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

118  {
119  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ISO_WRONG_LEVEL);
121  }
static checkIsolationLevel($isolation_level)
+ Here is the call graph for this function:

◆ testLockSameTable()

ilDatabaseAtomBaseTest::testLockSameTable ( )

Definition at line 248 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_IDENTICAL_TABLES.

249  {
250  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_IDENTICAL_TABLES);
251  $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
252  $ilAtomQuery->addTableLock('il_db_tests_atom');
253  $ilAtomQuery->addTableLock('il_db_tests_atom');
254  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) {
255  });
256  $ilAtomQuery->run();
257  }

◆ testLockSameTableWithAlias()

ilDatabaseAtomBaseTest::testLockSameTableWithAlias ( )

Definition at line 260 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_IDENTICAL_TABLES.

261  {
262  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_IDENTICAL_TABLES);
263  $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
264  $ilAtomQuery->addTableLock('il_db_tests_atom')->aliasName('alias_one');
265  $ilAtomQuery->addTableLock('il_db_tests_atom')->aliasName('alias_one');
266  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) {
267  });
268  $ilAtomQuery->run();
269  }

◆ testMultipleClosures()

ilDatabaseAtomBaseTest::testMultipleClosures ( )

Definition at line 236 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_CLOSURE_ALREADY_SET.

237  {
238  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_CLOSURE_ALREADY_SET);
239  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
240  $ilAtomQuery->addTableLock('object_data');
241  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) {
242  });
243  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) {
244  });
245  }

◆ testQueryWithFiveException()

ilDatabaseAtomBaseTest::testQueryWithFiveException ( )

Definition at line 174 of file ilDatabaseAtomBaseTest.php.

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

175  {
176  $counter = 0;
177  $max = 5;
178  $result = null;
179  $query = function (ilDBInterface $ilDBInterface) use (&$counter, &$max, &$result) {
180  if ($counter < $max) {
181  $counter++;
183  }
184  $result = $ilDBInterface->listTables();
185  };
186 
187  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
188  $ilAtomQuery->addQueryCallable($query);
189  $ilAtomQuery->addTableLock('object_data');
190  $ilAtomQuery->run();
191  $this->assertTrue(is_array($result));
192  }
$result
Class ilDatabaseException.
$query

◆ testQueryWithTenException()

ilDatabaseAtomBaseTest::testQueryWithTenException ( )

Definition at line 195 of file ilDatabaseAtomBaseTest.php.

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

196  {
197  $this->setExpectedException('ilDatabaseException', ilDatabaseException::DB_GENERAL);
198  $counter = 0;
199  $max = 10;
200  $result = null;
201  $query = function (ilDBInterface $ilDBInterface) use (&$counter, &$max, &$result) {
202  if ($counter < $max) {
203  $counter++;
205  }
206  $result = $ilDBInterface->listTables();
207  };
208 
209  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
210  $ilAtomQuery->addQueryCallable($query);
211  $ilAtomQuery->addTableLock('object_data');
212 
213  $ilAtomQuery->run();
214 
215  $this->assertTrue(is_null($result));
216  }
$result
Class ilDatabaseException.
$query

◆ testReadCommited()

ilDatabaseAtomBaseTest::testReadCommited ( )

Definition at line 94 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL, and ilAtomQuery\ISOLATION_READ_COMMITED.

95  {
96  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ISO_WRONG_LEVEL);
97  $other = new ilAtomQueryTransaction($this->ilDBInterfaceGalera, ilAtomQuery::ISOLATION_READ_COMMITED);
98  $other->run();
99  }
Class ilAtomQueryTransaction.

◆ testReadRepeatedRead()

ilDatabaseAtomBaseTest::testReadRepeatedRead ( )

Definition at line 102 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL, and ilAtomQuery\ISOLATION_REPEATED_READ.

103  {
104  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ISO_WRONG_LEVEL);
105  $other = new ilAtomQueryTransaction($this->ilDBInterfaceGalera, ilAtomQuery::ISOLATION_REPEATED_READ);
106  $other->run();
107  }
Class ilAtomQueryTransaction.

◆ testReadUncommited()

ilDatabaseAtomBaseTest::testReadUncommited ( )

Definition at line 86 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL, and ilAtomQuery\ISOLATION_READ_UNCOMMITED.

87  {
88  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_ISO_WRONG_LEVEL);
89  $other = new ilAtomQueryTransaction($this->ilDBInterfaceGalera, ilAtomQuery::ISOLATION_READ_UNCOMMITED);
90  $other->run();
91  }
Class ilAtomQueryTransaction.

◆ testRisks()

ilDatabaseAtomBaseTest::testRisks ( )

Definition at line 124 of file ilDatabaseAtomBaseTest.php.

125  {
126  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
127  $ilAtomQuery->addTableLock('object_data');
128  $this->assertEquals(array(), $ilAtomQuery->getRisks());
129  }

◆ testWithOutClosures()

ilDatabaseAtomBaseTest::testWithOutClosures ( )

Definition at line 227 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_CLOSURE_NONE.

228  {
229  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_CLOSURE_NONE);
230  $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
231  $ilAtomQuery->addTableLock('object_data');
232  $ilAtomQuery->run();
233  }

◆ testWithOutLocks()

ilDatabaseAtomBaseTest::testWithOutLocks ( )

Definition at line 219 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_LOCK_NO_TABLE.

220  {
221  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_LOCK_NO_TABLE);
222  $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
223  $ilAtomQuery->run();
224  }

◆ testWrongIsolationLevel()

ilDatabaseAtomBaseTest::testWrongIsolationLevel ( )

Definition at line 162 of file ilDatabaseAtomBaseTest.php.

References $ilDB, and ilDBInterface\getDBType().

163  {
164  $this->setExpectedException('ilDatabaseException');
165  $ilAtomQuery = new ilAtomQueryTransaction($this->ilDBInterfaceGalera, 'non_existing');
166  $ilAtomQuery->addTableLock('il_db_tests_atom');
167  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) {
168  $ilDB->getDBType();
169  });
170  $ilAtomQuery->run();
171  }
Class ilAtomQueryTransaction.
getDBType()
Get DSN.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilDatabaseAtomBaseTest::$backupGlobals = false
protected

Definition at line 43 of file ilDatabaseAtomBaseTest.php.

◆ $ilDBInterfaceGalera

ilDatabaseAtomBaseTest::$ilDBInterfaceGalera
protected

Definition at line 47 of file ilDatabaseAtomBaseTest.php.

◆ $ilDBInterfaceInnoDB

ilDatabaseAtomBaseTest::$ilDBInterfaceInnoDB
protected

Definition at line 51 of file ilDatabaseAtomBaseTest.php.


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