ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjTestDynamicQuestionSetConfigTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
26 {
28 
29  protected function setUp(): void
30  {
31  parent::setUp();
32 
33  $this->testObj = new ilObjTestDynamicQuestionSetConfig(
34  $this->getMockBuilder(ilTree::class)->disableOriginalConstructor()->getMock(),
35  $this->createMock(ilDBInterface::class),
36  $this->createMock(ilComponentRepository::class),
37  $this->getMockBuilder(ilObjTest::class)->disableOriginalConstructor()->getMock()
38  );
39  }
40 
42  {
43  $this->assertInstanceOf(ilObjTestDynamicQuestionSetConfig::class, $this->testObj);
44  }
45 
46  public function testSourceQuestionPoolId(): void
47  {
48  $this->testObj->setSourceQuestionPoolId(125);
49  $this->assertEquals(125, $this->testObj->getSourceQuestionPoolId());
50  }
51 
52  public function testSourceQuestionPoolTitle(): void
53  {
54  $this->testObj->setSourceQuestionPoolTitle("testString");
55  $this->assertEquals("testString", $this->testObj->getSourceQuestionPoolTitle());
56  }
57 
58  public function testAnswerStatusFilterEnabled(): void
59  {
60  $this->testObj->setAnswerStatusFilterEnabled(false);
61  $this->assertFalse($this->testObj->isAnswerStatusFilterEnabled());
62 
63  $this->testObj->setAnswerStatusFilterEnabled(true);
64  $this->assertTrue($this->testObj->isAnswerStatusFilterEnabled());
65  }
66 
67  public function testTaxonomyFilterEnabled(): void
68  {
69  $this->testObj->setTaxonomyFilterEnabled(false);
70  $this->assertFalse($this->testObj->isTaxonomyFilterEnabled());
71 
72  $this->testObj->setTaxonomyFilterEnabled(true);
73  $this->assertTrue($this->testObj->isTaxonomyFilterEnabled());
74  }
75 
76  public function testOrderingTaxonomyId(): void
77  {
78  $this->testObj->setOrderingTaxonomyId(1231);
79  $this->assertEquals(1231, $this->testObj->getOrderingTaxonomyId());
80  }
81 
82  public function testInitFromArray(): void
83  {
84  $expected = [
85  "source_qpl_fi" => 126,
86  "source_qpl_title" => "testString",
87  "answer_filter_enabled" => true,
88  "tax_filter_enabled" => false,
89  "order_tax" => 1369,
90  ];
91 
92  $this->testObj->initFromArray($expected);
93 
94  $this->assertEquals($expected["source_qpl_fi"], $this->testObj->getSourceQuestionPoolId());
95  $this->assertEquals($expected["source_qpl_title"], $this->testObj->getSourceQuestionPoolTitle());
96  $this->assertEquals($expected["answer_filter_enabled"], $this->testObj->isAnswerStatusFilterEnabled());
97  $this->assertEquals($expected["tax_filter_enabled"], $this->testObj->isTaxonomyFilterEnabled());
98  $this->assertEquals($expected["order_tax"], $this->testObj->getOrderingTaxonomyId());
99  }
100 
101  public function testIsQuestionSetConfigured(): void
102  {
103  $this->assertFalse($this->testObj->isQuestionSetConfigured());
104 
105  $this->testObj->setSourceQuestionPoolId(168);
106  $this->assertTrue($this->testObj->isQuestionSetConfigured());
107  }
108 
109  public function testDoesQuestionSetRelatedDataExist(): void
110  {
111  $this->assertFalse($this->testObj->isQuestionSetConfigured());
112  $this->assertFalse($this->testObj->doesQuestionSetRelatedDataExist());
113 
114  $this->testObj->setSourceQuestionPoolId(168);
115  $this->assertTrue($this->testObj->isQuestionSetConfigured());
116  $this->assertTrue($this->testObj->doesQuestionSetRelatedDataExist());
117  }
118 
120  {
121  $this->addGlobal_ilDB();
122 
123  $this->testObj->setSourceQuestionPoolId(16);
124  $this->testObj->setSourceQuestionPoolTitle("testTitle");
125 
126  $lng_mock = $this->createMock(ilLanguage::class);
127  $lng_mock->expects($this->any())
128  ->method("txt")
129  ->with("tst_dyn_quest_set_src_qpl_summary_string_deleted")
130  ->willReturn("testString");
131 
132  $result = $this->testObj->getSourceQuestionPoolSummaryString($lng_mock);
133 
134  $this->assertEquals("testString", $result);
135  }
136 
138  {
139  $this->addGlobal_ilDB();
140 
141  $this->testObj->setSourceQuestionPoolId(16);
142  $this->testObj->setSourceQuestionPoolTitle("testTitle");
143 
144  $lng_mock = $this->createMock(ilLanguage::class);
145  $lng_mock->expects($this->any())
146  ->method("txt")
147  ->with("tst_dyn_quest_set_pool_trashed")
148  ->willReturn("testString");
149 
150  $result = $this->testObj->getDepenciesInVulnerableStateMessage($lng_mock);
151 
152  $this->assertEquals("testString", $result);
153  }
154 
155  public function testAreDepenciesBroken(): void
156  {
157  $this->addGlobal_ilDB();
158 
159  $this->assertFalse($this->testObj->areDepenciesBroken());
160 
161  $this->testObj->setSourceQuestionPoolId(16);
162  $this->assertTrue($this->testObj->areDepenciesBroken());
163  }
164 
165  public function testGetDepenciesBrokenMessage(): void
166  {
167  $this->addGlobal_ilDB();
168 
169  $this->testObj->setSourceQuestionPoolId(16);
170  $this->testObj->setSourceQuestionPoolTitle("testTitle");
171 
172  $lng_mock = $this->createMock(ilLanguage::class);
173  $lng_mock->expects($this->any())
174  ->method("txt")
175  ->with("tst_dyn_quest_set_pool_deleted")
176  ->willReturn("testString");
177 
178  $result = $this->testObj->getDepenciesBrokenMessage($lng_mock);
179 
180  $this->assertEquals("testString", $result);
181  }
182 
183  public function testGetHiddenTabsOnBrokenDepencies(): void
184  {
185  $expected = [
186  'settings',
187  'manscoring',
188  'scoringadjust',
189  'statistics',
190  'history',
191  'export'
192  ];
193 
194  $result = $this->testObj->getHiddenTabsOnBrokenDepencies();
195  $this->assertEquals($expected, $result);
196  }
197 
198  public function testIsResultTaxonomyFilterSupported(): void
199  {
200  $this->assertFalse($this->testObj->isResultTaxonomyFilterSupported());
201  }
202 
203  public function testIsAnyQuestionFilterEnabled(): void
204  {
205  $this->assertFalse($this->testObj->isAnyQuestionFilterEnabled());
206 
207  $this->testObj->setTaxonomyFilterEnabled(false);
208  $this->assertFalse($this->testObj->isAnyQuestionFilterEnabled());
209 
210  $this->testObj->setTaxonomyFilterEnabled(true);
211  $this->assertTrue($this->testObj->isAnyQuestionFilterEnabled());
212  }
213 
214  /* ak: please do not make wrong assumptions on other components, aka testing unspecified
215  behaviour of other components. ilLink::_getLink needs a ref id, please provide one
216  public function testGetSourceQuestionPoolLink() : void
217  {
218  $this->addGlobal_ilDB();
219  $this->addGlobal_ilObjDataCache();
220 
221 
222  $this->testObj->setSourceQuestionPoolTitle("testTitle");
223  $this->testObj->setSourceQuestionPoolId(125);
224 
225  $result = $this->testObj->getSourceQuestionPoolLink();
226  $this->assertEquals(
227  '<a href="' . ILIAS_HTTP_PATH . '/goto.php?target=qpl_&client_id=' . CLIENT_ID . '" alt="' . $this->testObj->getSourceQuestionPoolTitle() . '">' . $this->testObj->getSourceQuestionPoolTitle() . '</a>',
228  $result
229  );
230  }*/
231 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilTestBaseClass.