ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilObjDataCollectionTest.php
Go to the documentation of this file.
1 <?php
2 include_once("./Services/Exceptions/classes/class.ilException.php");
3 
11 {
15  protected $root_object;
16 
17  protected $backupGlobals = false;
18 
19  protected function setUp()
20  {
21  PHPUnit_Framework_Error_Deprecated::$enabled = false;
22 // PHPUnit_Framework_Error_Warning::$enabled = FALSE;
23 // PHPUnit_Framework_Error_Notice::$enabled = FALSE;
24  parent::setUp();
25 
26  require_once("./Modules/DataCollection/classes/class.ilObjDataCollection.php");
27 
28  include_once("./Services/PHPUnit/classes/class.ilUnitUtil.php");
29  ilUnitUtil::performInitialisation();
30  $this->root_object = new ilObjDataCollection();
31  $this->root_object->setTitle('DataCollection');
32 
33  $this->root_object->create();
34  $this->root_object->createReference();
35  $this->root_object_obj_id = $this->root_object->getId();
36  $this->root_object_ref_id = $this->root_object->getRefId();
37  $this->root_object->putInTree(ROOT_FOLDER_ID);
38 
39  //
40 
41  global $DIC;
42  $tree = $DIC['tree'];
43  $this->tree = $tree;
44 
45  global $DIC;
46  $objDefinition = $DIC['objDefinition'];
47  $this->obj_definition = $objDefinition;
48  }
49 
50  protected function tearDown()
51  {
52  if ($this->root_object) {
53  $this->root_object->delete();
54  }
55  }
56 
60  public function testCreation()
61  {
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  {
73  $tables = $this->root_object->getTables();
74  $this->assertEquals(count($tables), 1);
75 
76  $table = array_shift($tables);
77  $this->assertTrue($table instanceof ilDclTable);
78  return $table;
79  }
80 
85  {
86 // $this->assertEquals($table->getId(), $this->root_object->getMainTableId());
87  $this->assertEquals($table->getTitle(), $this->root_object->getTitle());
88 // $this->assertEquals($table->getObjId(), $this->root_object_obj_id);
89  $this->assertFalse((bool) $table->getPublicCommentsEnabled());
90  $this->assertEmpty($table->getRecords());
91  $this->assertEmpty($table->getRecordFields());
92  $this->assertEquals(count($table->getFields()), count($table->getStandardFields()));
93 
94  $this->assertTrue($this->root_object->_hasTableByTitle($this->root_object->getTitle(), $this->root_object_obj_id));
95  }
96 
101  {
102  $tableviews = $table->getTableViews();
103  $this->assertEquals(count($tableviews), 1);
104 
105  $tableview = array_shift($tableviews);
106  $this->assertTrue($tableview instanceof ilDclTableView);
107  return array('table' => $table, 'tableview' => $tableview);
108  }
109 
113  public function testDefaultTableView(array $array)
114  {
115  $this->assertEquals(count(ilDclTableView::getAllForTableId($array['table']->getId())), 1);
116  $this->assertEquals($array['tableview']->getTable(), $array['table']);
117 
118  $this->assertEquals($array['tableview']->getOrder(), 10);
119  }
120 
124  public function testDefaultTableViewFieldSettings(array $array)
125  {
126  $field_settings = $array['tableview']->getFieldSettings();
127 // $this->assertEquals(count($field_settings), count($array['table']->getFields()) - $array['table']->getPublicCommentsEnabled());
128 
129  foreach ($array['table']->getFields() as $field) {
130  $f_sets = $field->getFieldSettings();
131  $this->assertNotEmpty($f_sets);
132  }
133  }
134 }
testCreation()
Test creation of ilObjStudyProgramme.
testDefaultTableViewCreated(ilDclTable $table)
testDefaultTableCreated
Class ilObjDataCollectionTest needsInstalledILIAS.
global $DIC
Definition: saml.php:7
testDefaultTableView(array $array)
testDefaultTableViewCreated
static getAllForTableId($table_id)
getFields()
Returns all fields of this table including the standard fields.
Class ilDclBaseFieldModel.
testDefaultTable(ilDclTable $table)
testDefaultTableCreated
Class ilDclTableView.
getRecordFields()
Returns all fields of this table which are NOT standard fields.
testDefaultTableViewFieldSettings(array $array)
testDefaultTableViewCreated
if(empty($password)) $table
Definition: pwgen.php:24
Class ilObjDataCollection.