ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjDataCollectionTest.php
Go to the documentation of this file.
1<?php
2include_once("./Services/Exceptions/classes/class.ilException.php");
3include_once("./Services/Database/classes/MDB2/class.ilDBInnoDB.php");
4
12{
16 protected $root_object;
17
18 protected $backupGlobals = FALSE;
19
20 protected function setUp()
21 {
22 PHPUnit_Framework_Error_Deprecated::$enabled = FALSE;
23// PHPUnit_Framework_Error_Warning::$enabled = FALSE;
24// PHPUnit_Framework_Error_Notice::$enabled = FALSE;
25 parent::setUp();
26
27 require_once("./Modules/DataCollection/classes/class.ilObjDataCollection.php");
28
29 include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
30 ilUnitUtil::performInitialisation();
31 $this->root_object = new ilObjDataCollection();
32 $this->root_object->setTitle('DataCollection');
33
34 $this->root_object->create();
35 $this->root_object->createReference();
36 $this->root_object_obj_id = $this->root_object->getId();
37 $this->root_object_ref_id = $this->root_object->getRefId();
38 $this->root_object->putInTree(ROOT_FOLDER_ID);
39
40 //
41
42 global $DIC;
43 $tree = $DIC['tree'];
44 $this->tree = $tree;
45
46 global $DIC;
47 $objDefinition = $DIC['objDefinition'];
48 $this->obj_definition = $objDefinition;
49
50 }
51
52 protected function tearDown() {
53 if ($this->root_object) {
54 $this->root_object->delete();
55 }
56 }
57
61 public function testCreation() {
62 $this->assertNotEmpty($this->root_object_obj_id);
63 $this->assertGreaterThan(0, $this->root_object_obj_id);
64
65 $this->assertNotEmpty($this->root_object_ref_id);
66 $this->assertGreaterThan(0, $this->root_object_ref_id);
67
68 $this->assertTrue($this->tree->isInTree($this->root_object_ref_id));
69 }
70
71 public function testDefaultTableCreated() {
72 $tables = $this->root_object->getTables();
73 $this->assertEquals(count($tables), 1);
74
75 $table = array_shift($tables);
76 $this->assertTrue($table instanceof ilDclTable);
77 return $table;
78 }
79
83 public function testDefaultTable(ilDclTable $table) {
84// $this->assertEquals($table->getId(), $this->root_object->getMainTableId());
85 $this->assertEquals($table->getTitle(), $this->root_object->getTitle());
86// $this->assertEquals($table->getObjId(), $this->root_object_obj_id);
87 $this->assertFalse((bool) $table->getPublicCommentsEnabled());
88 $this->assertEmpty($table->getRecords());
89 $this->assertEmpty($table->getRecordFields());
90 $this->assertEquals(count($table->getFields()), count($table->getStandardFields()));
91
92 $this->assertTrue($this->root_object->_hasTableByTitle($this->root_object->getTitle(), $this->root_object_obj_id));
93 }
94
98 public function testDefaultTableViewCreated(ilDclTable $table) {
99
100 $tableviews = $table->getTableViews();
101 $this->assertEquals(count($tableviews), 1);
102
103 $tableview = array_shift($tableviews);
104 $this->assertTrue($tableview instanceof ilDclTableView);
105 return array('table' => $table, 'tableview' => $tableview);
106 }
107
111 public function testDefaultTableView(array $array) {
112 $this->assertEquals(count(ilDclTableView::getAllForTableId($array['table']->getId())), 1);
113 $this->assertEquals($array['tableview']->getTable(), $array['table']);
114
115 $this->assertEquals($array['tableview']->getOrder(), 10);
116 }
117
121 public function testDefaultTableViewFieldSettings(array $array) {
122 $field_settings = $array['tableview']->getFieldSettings();
123// $this->assertEquals(count($field_settings), count($array['table']->getFields()) - $array['table']->getPublicCommentsEnabled());
124
125 foreach($array['table']->getFields() as $field) {
126 $f_sets = $field->getFieldSettings();
127 $this->assertNotEmpty($f_sets);
128 }
129 }
130
131
132}
An exception for terminatinating execution or to throw for unit testing.
Class ilDclTableView.
static getAllForTableId($table_id)
Class ilDclBaseFieldModel.
getRecordFields()
Returns all fields of this table which are NOT standard fields.
getFields()
Returns all fields of this table including the standard fields.
Class ilObjDataCollectionTest @group needsInstalledILIAS.
testDefaultTable(ilDclTable $table)
@depends testDefaultTableCreated
testDefaultTableViewFieldSettings(array $array)
@depends testDefaultTableViewCreated
testDefaultTableView(array $array)
@depends testDefaultTableViewCreated
testDefaultTableViewCreated(ilDclTable $table)
@depends testDefaultTableCreated
testCreation()
Test creation of ilObjStudyProgramme.
Class ilObjDataCollection.
global $DIC