ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilEvaluationAllTableGUITest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
26 {
29 
30  protected function setUp(): void
31  {
32  parent::setUp();
33 
34  $lng_mock = $this->createMock(ilLanguage::class);
35  $lng_mock->expects($this->any())
36  ->method("txt")
37  ->willReturnCallback(function () {
38  return "testTranslation";
39  });
40 
41  $ctrl_mock = $this->createMock(ilCtrl::class);
42  $ctrl_mock->expects($this->any())
43  ->method("getFormAction")
44  ->willReturnCallback(function () {
45  return "testFormAction";
46  });
47 
48  $this->setGlobalVariable("lng", $lng_mock);
49  $this->setGlobalVariable("ilCtrl", $ctrl_mock);
50  $this->setGlobalVariable("tpl", $this->createMock(ilGlobalPageTemplate::class));
51  $this->setGlobalVariable("component.repository", $this->createMock(ilComponentRepository::class));
52  $component_factory = $this->createMock(ilComponentFactory::class);
53  $component_factory->method("getActivePluginsInSlot")->willReturn(new ArrayIterator());
54  $this->setGlobalVariable("component.factory", $component_factory);
55  $this->setGlobalVariable("ilDB", $this->createMock(ilDBInterface::class));
56  $this->setGlobalVariable("ilSetting", $this->createMock(ilSetting::class));
57  $this->setGlobalVariable("rbacreview", $this->createMock(ilRbacReview::class));
58  $this->setGlobalVariable("ilUser", $this->createMock(ilObjUser::class));
59 
60  $this->parentObj_mock = $this->getMockBuilder(ilObjTestGUI::class)->disableOriginalConstructor()->onlyMethods(array('getObject'))->getMock();
61  $this->parentObj_mock->expects($this->any())->method('getObject')->willReturn($this->createMock(ilObjTest::class));
62  $this->tableGui = new ilEvaluationAllTableGUI($this->parentObj_mock, "");
63  }
64 
66  {
67  $this->assertInstanceOf(ilEvaluationAllTableGUI::class, $this->tableGui);
68  }
69 
70  public function testNumericOrdering(): void
71  {
72  $tableGui = new ilEvaluationAllTableGUI(
73  $this->parentObj_mock,
74  "",
75  false,
76  false
77  );
78  $this->assertTrue($tableGui->numericOrdering("reached"));
79  $this->assertTrue($tableGui->numericOrdering("hint_count"));
80  $this->assertTrue($tableGui->numericOrdering("exam_id"));
81  $this->assertFalse($tableGui->numericOrdering("name"));
82 
83  $tableGui = new ilEvaluationAllTableGUI(
84  $this->parentObj_mock,
85  "",
86  true,
87  true
88  );
89  $this->assertTrue($tableGui->numericOrdering("reached"));
90  $this->assertTrue($tableGui->numericOrdering("hint_count"));
91  $this->assertTrue($tableGui->numericOrdering("exam_id"));
92  $this->assertTrue($tableGui->numericOrdering("name"));
93 
94  $tableGui = new ilEvaluationAllTableGUI(
95  $this->parentObj_mock,
96  "",
97  true,
98  false
99  );
100  $this->assertTrue($tableGui->numericOrdering("reached"));
101  $this->assertTrue($tableGui->numericOrdering("hint_count"));
102  $this->assertTrue($tableGui->numericOrdering("exam_id"));
103  $this->assertTrue($tableGui->numericOrdering("name"));
104 
105  $tableGui = new ilEvaluationAllTableGUI(
106  $this->parentObj_mock,
107  "",
108  false,
109  true
110  );
111  $this->assertTrue($tableGui->numericOrdering("reached"));
112  $this->assertTrue($tableGui->numericOrdering("hint_count"));
113  $this->assertTrue($tableGui->numericOrdering("exam_id"));
114  $this->assertFalse($tableGui->numericOrdering("name"));
115  }
116 
117  public function testGetSelectableColumns()
118  {
119  $expected = [
120  "gender" => [
121  "txt" => "testTranslation",
122  "default" => false,
123  ],
124  "email" => [
125  "txt" => "testTranslation",
126  "default" => false,
127  ],
128  "institution" => [
129  "txt" => "testTranslation",
130  "default" => false,
131  ],
132  "street" => [
133  "txt" => "testTranslation",
134  "default" => false,
135  ],
136  "city" => [
137  "txt" => "testTranslation",
138  "default" => false,
139  ],
140  "zipcode" => [
141  "txt" => "testTranslation",
142  "default" => false,
143  ],
144  "department" => [
145  "txt" => "testTranslation",
146  "default" => false,
147  ],
148  "matriculation" => [
149  "txt" => "testTranslation",
150  "default" => false,
151  ],
152  ];
153 
154  $tableGui = new ilEvaluationAllTableGUI(
155  $this->parentObj_mock,
156  "",
157  false,
158  false
159  );
160 
161  $this->assertEquals($expected, $tableGui->getSelectableColumns());
162 
163  $tableGui = new ilEvaluationAllTableGUI(
164  $this->parentObj_mock,
165  "",
166  true,
167  false
168  );
169 
170  $this->assertEquals([], $tableGui->getSelectableColumns());
171  }
172 
173  public function testGetSelectedColumns(): void
174  {
175  $expected = [];
176  $this->assertEquals($expected, $this->tableGui->getSelectedColumns());
177  }
178 }
Class ilObjTestGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setGlobalVariable(string $name, $value)
Class ilTestBaseClass.
numericOrdering(string $a_field)
Should this field be sorted numeric?