ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 53 of file ilDatabaseAtomBaseTest.php.

References ilDBConstants\TYPE_GALERA, and ilDBConstants\TYPE_PDO_MYSQL_INNODB.

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

◆ testAnomalies()

ilDatabaseAtomBaseTest::testAnomalies ( )

Definition at line 104 of file ilDatabaseAtomBaseTest.php.

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

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

◆ testCallables()

ilDatabaseAtomBaseTest::testCallables ( )

Definition at line 123 of file ilDatabaseAtomBaseTest.php.

123  {
124  require_once('./Services/Database/classes/PDO/class.ilDBPdoMySQL.php');
125  require_once('./Services/Database/test/Atom/data/class.ilAtomQueryTestHelper.php');
126 
127  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
128  // Working
129  $this->assertTrue($ilAtomQuery->checkCallable(function (ilDBInterface $ilDBInterface) { })); // ilDBInterface as first Parameter
130  $this->assertTrue($ilAtomQuery->checkCallable(new ilAtomQueryTestHelper())); // Class with implemented __invoke
131 
132  // Non working
133  $this->assertFalse($ilAtomQuery->checkCallable(function () { })); // No Parameter
134  $this->assertFalse($ilAtomQuery->checkCallable(function (ilDBInterface $ilDBInterface, $someOtherParameter) { })); // More than one parameter
135  $this->assertFalse($ilAtomQuery->checkCallable(function ($someOtherParameter, ilDBInterface $ilDBInterface) { })); // ilDBInterface not first parameter
136  $this->assertFalse($ilAtomQuery->checkCallable(function (ilDBPdoMySQL $ilDBInterface) { })); // not ilDBInterface
137  $this->assertFalse($ilAtomQuery->checkCallable(function ($ilDBInterface) { })); // not ilDBInterface
138  function noClosure() { }
139 
140  $this->assertFalse($ilAtomQuery->checkCallable('noClosure')); // Not a Closure
141 
142  }
Class ilDBPdoMySQL.
Interface ilDBInterface.
Class ilAtomQueryTestHelper.

◆ testGetInstance()

ilDatabaseAtomBaseTest::testGetInstance ( )

Definition at line 72 of file ilDatabaseAtomBaseTest.php.

References ilAtomQuery\ISOLATION_SERIALIZABLE.

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 ilAtomQueryTransaction.
Class ilAtomQueryLock.

◆ testLevel()

ilDatabaseAtomBaseTest::testLevel ( )

Definition at line 110 of file ilDatabaseAtomBaseTest.php.

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

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

◆ testLockSameTable()

ilDatabaseAtomBaseTest::testLockSameTable ( )

Definition at line 223 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_IDENTICAL_TABLES.

223  {
224  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_IDENTICAL_TABLES);
225  $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
226  $ilAtomQuery->addTableLock('il_db_tests_atom');
227  $ilAtomQuery->addTableLock('il_db_tests_atom');
228  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) { });
229  $ilAtomQuery->run();
230  }
Interface ilDBInterface.

◆ testLockSameTableWithAlias()

ilDatabaseAtomBaseTest::testLockSameTableWithAlias ( )

Definition at line 233 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_IDENTICAL_TABLES.

233  {
234  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_IDENTICAL_TABLES);
235  $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
236  $ilAtomQuery->addTableLock('il_db_tests_atom')->aliasName('alias_one');
237  $ilAtomQuery->addTableLock('il_db_tests_atom')->aliasName('alias_one');
238  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) { });
239  $ilAtomQuery->run();
240  }
Interface ilDBInterface.

◆ testMultipleClosures()

ilDatabaseAtomBaseTest::testMultipleClosures ( )

Definition at line 214 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_CLOSURE_ALREADY_SET.

214  {
215  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_CLOSURE_ALREADY_SET);
216  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
217  $ilAtomQuery->addTableLock('object_data');
218  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) { });
219  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDBInterface) { });
220  }
Interface ilDBInterface.

◆ testQueryWithFiveException()

ilDatabaseAtomBaseTest::testQueryWithFiveException ( )

Definition at line 156 of file ilDatabaseAtomBaseTest.php.

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

156  {
157  $counter = 0;
158  $max = 5;
159  $result = null;
160  $query = function (ilDBInterface $ilDBInterface) use (&$counter, &$max, &$result) {
161  if ($counter < $max) {
162  $counter ++;
164  }
165  $result = $ilDBInterface->listTables();
166  };
167 
168  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
169  $ilAtomQuery->addQueryCallable($query);
170  $ilAtomQuery->addTableLock('object_data');
171  $ilAtomQuery->run();
172  $this->assertTrue(is_array($result));
173  }
$result
Class ilDatabaseException.
$counter
Interface ilDBInterface.

◆ testQueryWithTenException()

ilDatabaseAtomBaseTest::testQueryWithTenException ( )

Definition at line 176 of file ilDatabaseAtomBaseTest.php.

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

176  {
177  $this->setExpectedException('ilDatabaseException', ilDatabaseException::DB_GENERAL);
178  $counter = 0;
179  $max = 10;
180  $result = null;
181  $query = function (ilDBInterface $ilDBInterface) use (&$counter, &$max, &$result) {
182  if ($counter < $max) {
183  $counter ++;
185  }
186  $result = $ilDBInterface->listTables();
187  };
188 
189  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
190  $ilAtomQuery->addQueryCallable($query);
191  $ilAtomQuery->addTableLock('object_data');
192 
193  $ilAtomQuery->run();
194 
195  $this->assertTrue(is_null($result));
196  }
$result
Class ilDatabaseException.
$counter
Interface ilDBInterface.

◆ testReadCommited()

ilDatabaseAtomBaseTest::testReadCommited ( )

Definition at line 90 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL, and ilAtomQuery\ISOLATION_READ_COMMITED.

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

◆ testReadRepeatedRead()

ilDatabaseAtomBaseTest::testReadRepeatedRead ( )

Definition at line 97 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL, and ilAtomQuery\ISOLATION_REPEATED_READ.

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

◆ testReadUncommited()

ilDatabaseAtomBaseTest::testReadUncommited ( )

Definition at line 83 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_ISO_WRONG_LEVEL, and ilAtomQuery\ISOLATION_READ_UNCOMMITED.

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

◆ testRisks()

ilDatabaseAtomBaseTest::testRisks ( )

Definition at line 116 of file ilDatabaseAtomBaseTest.php.

References array.

116  {
117  $ilAtomQuery = $this->ilDBInterfaceGalera->buildAtomQuery();
118  $ilAtomQuery->addTableLock('object_data');
119  $this->assertEquals(array(), $ilAtomQuery->getRisks());
120  }
Create styles array
The data for the language used.

◆ testWithOutClosures()

ilDatabaseAtomBaseTest::testWithOutClosures ( )

Definition at line 206 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_CLOSURE_NONE.

206  {
207  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_CLOSURE_NONE);
208  $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
209  $ilAtomQuery->addTableLock('object_data');
210  $ilAtomQuery->run();
211  }

◆ testWithOutLocks()

ilDatabaseAtomBaseTest::testWithOutLocks ( )

Definition at line 199 of file ilDatabaseAtomBaseTest.php.

References ilAtomQueryException\DB_ATOM_LOCK_NO_TABLE.

199  {
200  $this->setExpectedException('ilAtomQueryException', ilAtomQueryException::DB_ATOM_LOCK_NO_TABLE);
201  $ilAtomQuery = $this->ilDBInterfaceInnoDB->buildAtomQuery();
202  $ilAtomQuery->run();
203  }

◆ testWrongIsolationLevel()

ilDatabaseAtomBaseTest::testWrongIsolationLevel ( )

Definition at line 145 of file ilDatabaseAtomBaseTest.php.

References $ilDB, and ilDBInterface\getDBType().

145  {
146  $this->setExpectedException('ilDatabaseException');
147  $ilAtomQuery = new ilAtomQueryTransaction($this->ilDBInterfaceGalera, 'non_existing');
148  $ilAtomQuery->addTableLock('il_db_tests_atom');
149  $ilAtomQuery->addQueryCallable(function (ilDBInterface $ilDB) {
150  $ilDB->getDBType();
151  });
152  $ilAtomQuery->run();
153  }
Class ilAtomQueryTransaction.
Interface ilDBInterface.
getDBType()
Get DSN.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilDatabaseAtomBaseTest::$backupGlobals = false
protected

Definition at line 42 of file ilDatabaseAtomBaseTest.php.

◆ $ilDBInterfaceGalera

ilDatabaseAtomBaseTest::$ilDBInterfaceGalera
protected

Definition at line 46 of file ilDatabaseAtomBaseTest.php.

◆ $ilDBInterfaceInnoDB

ilDatabaseAtomBaseTest::$ilDBInterfaceInnoDB
protected

Definition at line 50 of file ilDatabaseAtomBaseTest.php.


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