ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilEvaluationAllTableGUITest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
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, "", $this->createMock(ilSetting::class));
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  $this->createMock(ilSetting::class),
76  false,
77  false
78  );
79  $this->assertTrue($tableGui->numericOrdering("reached"));
80  $this->assertTrue($tableGui->numericOrdering("hint_count"));
81  $this->assertTrue($tableGui->numericOrdering("exam_id"));
82  $this->assertFalse($tableGui->numericOrdering("name"));
83 
84  $tableGui = new ilEvaluationAllTableGUI(
85  $this->parentObj_mock,
86  "",
87  $this->createMock(ilSetting::class),
88  true,
89  true
90  );
91  $this->assertTrue($tableGui->numericOrdering("reached"));
92  $this->assertTrue($tableGui->numericOrdering("hint_count"));
93  $this->assertTrue($tableGui->numericOrdering("exam_id"));
94  $this->assertTrue($tableGui->numericOrdering("name"));
95 
96  $tableGui = new ilEvaluationAllTableGUI(
97  $this->parentObj_mock,
98  "",
99  $this->createMock(ilSetting::class),
100  true,
101  false
102  );
103  $this->assertTrue($tableGui->numericOrdering("reached"));
104  $this->assertTrue($tableGui->numericOrdering("hint_count"));
105  $this->assertTrue($tableGui->numericOrdering("exam_id"));
106  $this->assertTrue($tableGui->numericOrdering("name"));
107 
108  $tableGui = new ilEvaluationAllTableGUI(
109  $this->parentObj_mock,
110  "",
111  $this->createMock(ilSetting::class),
112  false,
113  true
114  );
115  $this->assertTrue($tableGui->numericOrdering("reached"));
116  $this->assertTrue($tableGui->numericOrdering("hint_count"));
117  $this->assertTrue($tableGui->numericOrdering("exam_id"));
118  $this->assertFalse($tableGui->numericOrdering("name"));
119  }
120 
121  public function testGetSelectableColumns()
122  {
123  $expected = [
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  $this->createMock(ilSetting::class),
158  false,
159  false
160  );
161 
162  $this->assertEquals($expected, $tableGui->getSelectableColumns());
163 
164  $tableGui = new ilEvaluationAllTableGUI(
165  $this->parentObj_mock,
166  "",
167  $this->createMock(ilSetting::class),
168  true,
169  false
170  );
171 
172  $this->assertEquals([], $tableGui->getSelectableColumns());
173  }
174 
175  public function testGetSelectedColumns(): void
176  {
177  $expected = [];
178  $this->assertEquals($expected, $this->tableGui->getSelectedColumns());
179  }
180 }
Class ilObjTestGUI.
TableGUI class for evaluation of all users.
Class ilEvaluationAllTableGUITest.
setGlobalVariable(string $name, $value)
Class ilTestBaseClass.
numericOrdering(string $a_field)
Should this field be sorted numeric?