ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammeTypeRepositoryTest Class Reference

needsInstalledILIAS More...

+ Inheritance diagram for ilStudyProgrammeTypeRepositoryTest:
+ Collaboration diagram for ilStudyProgrammeTypeRepositoryTest:

Public Member Functions

 setUp ()
 
 test_init ()
 
 test_amds ()
 test_init More...
 
 type_translations ()
 test_init More...
 
 test_type_create ()
 test_init More...
 
 test_type_title_description ()
 test_type_create More...
 
 test_type_amd ()
 
 test_type_delete ()
 

Static Public Member Functions

static tearDownAfterClass ()
 

Protected Attributes

 $backupGlobals = false
 

Static Protected Attributes

static $created_amd = []
 
static $created_tt = []
 
static $created_type = []
 

Detailed Description

needsInstalledILIAS

Definition at line 6 of file ilStudyProgrammeTypeRepositoryTest.php.

Member Function Documentation

◆ setUp()

ilStudyProgrammeTypeRepositoryTest::setUp ( )

Definition at line 13 of file ilStudyProgrammeTypeRepositoryTest.php.

References $DIC, Vendor\Package\$e, and ilStudyProgrammeDIC\dic().

13  : void
14  {
15  PHPUnit_Framework_Error_Deprecated::$enabled = false;
16 
17  global $DIC;
18  if (!$DIC) {
19  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
20  try {
21  ilUnitUtil::performInitialisation();
22  } catch (\Exception $e) {
23  }
24  }
25  $this->tr = ilStudyProgrammeDIC::dic()['model.Type.ilStudyProgrammeTypeRepository'];
26  }
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ tearDownAfterClass()

static ilStudyProgrammeTypeRepositoryTest::tearDownAfterClass ( )
static

Definition at line 240 of file ilStudyProgrammeTypeRepositoryTest.php.

References $DIC, Vendor\Package\$e, $type, ilStudyProgrammeTypeDBRepository\AMD_TABLE, ilStudyProgrammeDIC\dic(), ilStudyProgrammeTypeDBRepository\FIELD_ID, and ilStudyProgrammeTypeDBRepository\TYPE_TRANSLATION_TABLE.

240  : void
241  {
242  global $DIC;
243  if (!$DIC) {
244  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
245  try {
246  ilUnitUtil::performInitialisation();
247  } catch (\Exception $e) {
248  }
249  }
250  global $DIC;
251  $db = $DIC['ilDB'];
252  $db->manipulate(
254  . ' WHERE ' . $db->in(
256  array_map(function ($amd) {
257  return $amd->getId();
258  }, self::$created_amd),
259  false,
260  'integer'
261  )
262  );
263  $db->manipulate(
265  . ' WHERE ' . $db->in(
267  array_map(function ($amd) {
268  return $tt->getId();
269  }, self::$created_tt),
270  false,
271  'integer'
272  )
273  );
274  $tr = ilStudyProgrammeDIC::dic()['model.Type.ilStudyProgrammeTypeRepository'];
275  $types = array_keys($tr->readAllTypesArray());
276  foreach (self::$created_type as $type) {
277  if (in_array($type->getId(), $types)) {
278  $tr->deleteType($type);
279  }
280  }
281  }
$type
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ test_amds()

ilStudyProgrammeTypeRepositoryTest::test_amds ( )

test_init

Definition at line 36 of file ilStudyProgrammeTypeRepositoryTest.php.

37  {
38  $tr = $this->tr;
39 
40  $amd = $tr->createAMDRecord();
41  self::$created_amd[] = $amd;
42  $this->assertEquals($amd->getTypeId(), 0);
43  $this->assertEquals($amd->getRecId(), 0);
44  $amd->setTypeId(-1);
45  $amd->setRecId(-2);
46  $tr->updateAMDRecord($amd);
47 
48  $amd = $tr->createAMDRecord();
49  self::$created_amd[] = $amd;
50  $amd->setTypeId(-1);
51  $amd->setRecId(-3);
52  $tr->updateAMDRecord($amd);
53 
54  $amd = $tr->createAMDRecord();
55  self::$created_amd[] = $amd;
56  $amd->setTypeId(-2);
57  $amd->setRecId(-3);
58  $tr->updateAMDRecord($amd);
59 
60  $amds = $tr->readAMDRecordsByTypeIdAndRecordId(-1, -2);
61  $this->assertCount(1, $amds);
62  foreach ($amds as $amd) {
63  $this->assertEquals($amd->getTypeId(), -1);
64  $this->assertEquals($amd->getRecId(), -2);
65  }
66 
67  $amds = $tr->readAMDRecordsByTypeId(-1);
68  $this->assertCount(2, $amds);
69  foreach ($amds as $amd) {
70  $this->assertEquals($amd->getTypeId(), -1);
71  }
72 
73  $amd = array_shift($tr->readAMDRecordsByTypeId(-2));
74  $tr->deleteAMDRecord($amd);
75  $this->assertCount(0, $tr->readAMDRecordsByTypeId(-2));
76  }

◆ test_init()

ilStudyProgrammeTypeRepositoryTest::test_init ( )

Definition at line 28 of file ilStudyProgrammeTypeRepositoryTest.php.

29  {
30  $this->assertInstanceOf(ilStudyProgrammeTypeRepository::class, $this->tr);
31  }

◆ test_type_amd()

ilStudyProgrammeTypeRepositoryTest::test_type_amd ( )

Definition at line 206 of file ilStudyProgrammeTypeRepositoryTest.php.

References $type, and test_type_create().

207  {
208  $tr = $this->tr;
209  $type = $this->test_type_create();
210  $amd = $tr->createAMDRecord();
211  $amd->setRecId(-31);
212  $amd->setTypeId($type->getId());
213  $tr->updateAMDRecord($amd);
214  $this->assertEquals([-31], $tr->readAssignedAMDRecordIdsByType($type->getId()));
215  $type->deassignAdvancedMdRecord(-31);
216  $this->assertEquals([], $tr->readAssignedAMDRecordIdsByType($type->getId(), true));
217  }
$type
+ Here is the call graph for this function:

◆ test_type_create()

ilStudyProgrammeTypeRepositoryTest::test_type_create ( )

test_init

Definition at line 157 of file ilStudyProgrammeTypeRepositoryTest.php.

References $type.

Referenced by test_type_amd(), test_type_delete(), and test_type_title_description().

158  {
159  $tr = $this->tr;
160  $type = $tr->createType('fr');
161  $this->assertEquals('fr', $type->getDefaultLang());
162  $this->assertEquals('', $type->getIcon());
163  self::$created_type[] = $type;
164  return $type;
165  }
$type
+ Here is the caller graph for this function:

◆ test_type_delete()

ilStudyProgrammeTypeRepositoryTest::test_type_delete ( )

Definition at line 219 of file ilStudyProgrammeTypeRepositoryTest.php.

References $type, and test_type_create().

220  {
221  $tr = $this->tr;
222  $type = $this->test_type_create();
223  $type_id = $type->getId();
224  $type->setTitle('a_title', 'de');
225  $type->setDescription('a_description', 'de');
226 
227  $amd = $tr->createAMDRecord();
228  $amd->setRecId(-32);
229  $amd->setTypeId($type_id);
230  $tr->updateAMDRecord($amd);
231 
232  $this->assertEquals([-32], $tr->readAssignedAMDRecordIdsByType($type_id));
233 
234  $this->tr->deleteType($type);
235  $this->assertNull($tr->readTranslationByTypeIdMemberLang($type_id, 'title', 'de'));
236  $this->assertNull($tr->readTranslationByTypeIdMemberLang($type_id, 'description', 'de'));
237  $this->assertEquals([], $tr->readAssignedAMDRecordIdsByType($type_id));
238  }
$type
+ Here is the call graph for this function:

◆ test_type_title_description()

ilStudyProgrammeTypeRepositoryTest::test_type_title_description ( )

test_type_create

Definition at line 170 of file ilStudyProgrammeTypeRepositoryTest.php.

References $type, and test_type_create().

171  {
172  $tr = $this->tr;
173  $type = $this->test_type_create();
174  $this->assertEquals('', $type->getTitle('de'));
175  $this->assertEquals('', $type->getDescription('de'));
176 
177  $type->setTitle('a_title', 'de');
178  $type->setDescription('a_description', 'de');
179 
180  $type_id = $type->getId();
181  $trans = $tr->readTranslationByTypeIdMemberLang($type_id, 'title', 'de');
182  $this->assertEquals('title', $trans->getMember());
183  $this->assertEquals('a_title', $trans->getValue());
184  $this->assertEquals('de', $trans->getLang());
185 
186 
187  $trans = $tr->readTranslationByTypeIdMemberLang($type_id, 'description', 'de');
188  $this->assertEquals('description', $trans->getMember());
189  $this->assertEquals('a_description', $trans->getValue());
190  $this->assertEquals('de', $trans->getLang());
191 
192  $type = $tr->readType($type_id);
193  $this->assertEquals('a_title', $type->getTitle('de'));
194  $this->assertEquals('a_description', $type->getDescription('de'));
195 
196  $this->assertEquals('', $type->getTitle());
197  $this->assertEquals('', $type->getDescription());
198 
199 
200  $type->setTitle('a_title_def', 'fr');
201  $type->setDescription('a_description_def', 'fr');
202  $this->assertEquals('a_title_def', $type->getTitle());
203  $this->assertEquals('a_description_def', $type->getDescription());
204  }
$type
+ Here is the call graph for this function:

◆ type_translations()

ilStudyProgrammeTypeRepositoryTest::type_translations ( )

test_init

Definition at line 81 of file ilStudyProgrammeTypeRepositoryTest.php.

82  {
83  $tr = $this->tr;
84 
85  $tt = $tr->createTypeTranslation();
86  self::$created_tt[] = $tt;
87  $this->assertEquals($tt->getPrgTypeId(), 0);
88  $this->assertEquals($tt->getLang(), '');
89  $this->assertEquals($tt->getMember(), '');
90  $this->assertEquals($tt->getValue(), '');
91  $tt->setPrgTypeId(-10);
92  $tt->setLang('de');
93  $tt->setMember('a_member1');
94  $tt->setValue('a_value1');
95  $tr->updateTypeTranslation($tt);
96 
97  $tt = $tr->createTypeTranslation();
98  self::$created_tt[] = $tt;
99  $tt->setPrgTypeId(-10);
100  $tt->setLang('de');
101  $tt->setMember('a_member2');
102  $tt->setValue('a_value2');
103  $tr->updateTypeTranslation($tt);
104 
105  $tt = $tr->createTypeTranslation();
106  self::$created_tt[] = $tt;
107  $tt->setPrgTypeId(-11);
108  $tt->setLang('de');
109  $tt->setMember('a_member3');
110  $tt->setValue('a_value3');
111  $tr->updateTypeTranslation($tt);
112 
113  $tt = $tr->createTypeTranslation();
114  self::$created_tt[] = $tt;
115  $tt->setPrgTypeId(-10);
116  $tt->setLang('en');
117  $tt->setMember('a_member4');
118  $tt->setValue('a_value4');
119  $tr->updateTypeTranslation($tt);
120 
121  $tts = $tr->readTranslationsByTypeAndLang(-10, 'de');
122  $this->assertCount(0, $tts);
123  foreach ($tts as $tt) {
124  $this->assertEquals($tt->getPrgTypeId(), -10);
125  $this->assertEquals($tt->getLang(), 'de');
126  }
127 
128  $this->assertEquals(
129  array_map(function ($ts) {
130  return $ts->getMember();
131  }, $tts),
132  ['a_member1','a_member2']
133  );
134  $this->assertEquals(
135  array_map(function ($ts) {
136  return $ts->getValue();
137  }, $tts),
138  ['a_value1','a_value2']
139  );
140 
141 
142  $this->assertNull($tr->readTranslationByTypeIdMemberLang(-10, 'en', 'a_member1'));
143  $tt = $tr->readTranslationByTypeIdMemberLang(-10, 'en', 'a_member4');
144  $this->assertEquals($tt->getPrgTypeId(), -10);
145  $this->assertEquals($tt->getLang(), 'en');
146  $this->assertEquals($tt->getMember(), 'a_member4');
147  $this->assertEquals($tt->getValue(), 'a_value4');
148 
149  $tr->deleteTypeTranslation($tt);
150  $this->assertNull($tr->readTranslationByTypeIdMemberLang(-10, 'en', 'a_member4'));
151  }

Field Documentation

◆ $backupGlobals

ilStudyProgrammeTypeRepositoryTest::$backupGlobals = false
protected

Definition at line 8 of file ilStudyProgrammeTypeRepositoryTest.php.

◆ $created_amd

ilStudyProgrammeTypeRepositoryTest::$created_amd = []
staticprotected

Definition at line 10 of file ilStudyProgrammeTypeRepositoryTest.php.

◆ $created_tt

ilStudyProgrammeTypeRepositoryTest::$created_tt = []
staticprotected

Definition at line 11 of file ilStudyProgrammeTypeRepositoryTest.php.

◆ $created_type

ilStudyProgrammeTypeRepositoryTest::$created_type = []
staticprotected

Definition at line 12 of file ilStudyProgrammeTypeRepositoryTest.php.


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