ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
SplEditingGUIRequestTest.php
Go to the documentation of this file.
1<?php
2
3use PHPUnit\Framework\TestCase;
4
10class SplEditingGUIRequestTest extends TestCase
11{
12 protected function tearDown(): void
13 {
14 }
15
16 protected function getRequest(array $get, array $post): \ILIAS\SurveyQuestionPool\Editing\EditingGUIRequest
17 {
18 $http_mock = $this->createMock(ILIAS\HTTP\Services::class);
19 $lng_mock = $this->createMock(ilLanguage::class);
20 $data = new \ILIAS\Data\Factory();
21 $refinery = new \ILIAS\Refinery\Factory($data, $lng_mock);
22 return new \ILIAS\SurveyQuestionPool\Editing\EditingGUIRequest(
23 $http_mock,
25 $get,
26 $post
27 );
28 }
29
30 public function testRefId(): void
31 {
32 $request = $this->getRequest(
33 [
34 "ref_id" => 102
35 ],
36 []
37 );
38
39 $this->assertEquals(
40 102,
41 $request->getRefId()
42 );
43 }
44
45 public function testQuestionId(): void
46 {
47 $request = $this->getRequest(
48 [
49 "q_id" => 33
50 ],
51 []
52 );
53
54 $this->assertEquals(
55 33,
56 $request->getQuestionId()
57 );
58 }
59
60 public function testQuestionIds(): void
61 {
62 $request = $this->getRequest(
63 [
64
65 ],
66 [
67 "q_id" => ["13", "15", "19"]
68 ]
69 );
70
71 $this->assertEquals(
72 [13, 15, 19],
73 $request->getQuestionIds()
74 );
75 }
76
77 public function testPreview(): void
78 {
79 $request = $this->getRequest(
80 [
81 "preview" => 1
82 ],
83 []
84 );
85
86 $this->assertEquals(
87 1,
88 $request->getPreview()
89 );
90 }
91
92 public function testSelectedQuestionTypes(): void
93 {
94 $request = $this->getRequest(
95 [
96 "sel_question_types" => "Metric"
97 ],
98 []
99 );
100
101 $this->assertEquals(
102 "Metric",
103 $request->getSelectedQuestionTypes()
104 );
105 }
106
107 public function testSort(): void
108 {
109 $request = $this->getRequest(
110 [
111
112 ],
113 [
114 "sort" => [
115 "a" => "a1",
116 "b" => "b1",
117 "c" => "c1",
118 ]
119 ]
120 );
121
122 $this->assertEquals(
123 [
124 "a" => "a1",
125 "b" => "b1",
126 "c" => "c1",
127 ],
128 $request->getSort()
129 );
130 }
131
132 public function testPhraseId(): void
133 {
134 $request = $this->getRequest(
135 [
136 "p_id" => 55
137 ],
138 []
139 );
140
141 $this->assertEquals(
142 55,
143 $request->getPhraseId()
144 );
145 }
146
147 public function testPhraseIds(): void
148 {
149 $request = $this->getRequest(
150 [
151
152 ],
153 [
154 "phrase" => ["13", "15", "19"]
155 ]
156 );
157
158 $this->assertEquals(
159 [13, 15, 19],
160 $request->getPhraseIds()
161 );
162 }
163}
Test editing request class.
getRequest(array $get, array $post)
$post
Definition: ltitoken.php:49
Refinery Factory $refinery
Class ChatMainBarProvider \MainMenu\Provider.