ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CatStandardGUIRequestTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
28class CatStandardGUIRequestTest extends TestCase
29{
30 protected function tearDown(): void
31 {
32 }
33
34 protected function getRequest(array $get, array $post): \ILIAS\Category\StandardGUIRequest
35 {
36 $http_mock = $this->createMock(ILIAS\HTTP\Services::class);
37 $lng_mock = $this->createMock(ilLanguage::class);
38 $data = new \ILIAS\Data\Factory();
39 $refinery = new \ILIAS\Refinery\Factory($data, $lng_mock);
40 return new \ILIAS\Category\StandardGUIRequest(
41 $http_mock,
43 $get,
44 $post
45 );
46 }
47
51 public function testRefId(): void
52 {
53 $request = $this->getRequest(
54 [
55 "ref_id" => "5"
56 ],
57 []
58 );
59
60 $this->assertEquals(
61 5,
62 $request->getRefId()
63 );
64 }
65
69 public function testNoRefId(): void
70 {
71 $request = $this->getRequest(
72 [
73 ],
74 []
75 );
76
77 $this->assertEquals(
78 0,
79 $request->getRefId()
80 );
81 }
82
86 public function testBaseClass(): void
87 {
88 $request = $this->getRequest(
89 [
90 "baseClass" => "myClass"
91 ],
92 []
93 );
94
95 $this->assertEquals(
96 "myClass",
97 $request->getBaseClass()
98 );
99 }
100
104 public function testCmdClass(): void
105 {
106 $request = $this->getRequest(
107 [
108 "cmdClass" => "myClass"
109 ],
110 []
111 );
112
113 $this->assertEquals(
114 "myClass",
115 $request->getCmdClass()
116 );
117 }
118
122 public function testTerm(): void
123 {
124 $request = $this->getRequest(
125 [
126 "term" => "my_term"
127 ],
128 []
129 );
130
131 $this->assertEquals(
132 "my_term",
133 $request->getTerm()
134 );
135 }
136
140 public function testTermByPost(): void
141 {
142 $request = $this->getRequest(
143 [
144 ],
145 [
146 "term" => "my_term"
147 ]
148 );
149
150 $this->assertEquals(
151 "my_term",
152 $request->getTerm()
153 );
154 }
155
159 public function testPostBeatsGet(): void
160 {
161 $request = $this->getRequest(
162 [
163 "term" => "one"
164 ],
165 [
166 "term" => "two"
167 ]
168 );
169
170 $this->assertEquals(
171 "two",
172 $request->getTerm()
173 );
174 }
175
179 public function testFetchAll(): void
180 {
181 $request = $this->getRequest(
182 [
183 "fetchall" => "1"
184 ],
185 []
186 );
187
188 $this->assertEquals(
189 1,
190 $request->getFetchAll()
191 );
192 }
193
197 public function testRoleIds(): void
198 {
199 $request = $this->getRequest(
200 [
201 ],
202 [
203 "role_ids" => [
204 "6", "7", "9"
205 ]
206 ]
207 );
208
209 $this->assertEquals(
210 [6,7,9],
211 $request->getRoleIds()
212 );
213 }
214
218 public function testUserIds(): void
219 {
220 $request = $this->getRequest(
221 [
222 ],
223 [
224 "user_ids" => [
225 "6", "7", "10"
226 ]
227 ]
228 );
229
230 $this->assertEquals(
231 [6,7,10],
232 $request->getUserIds()
233 );
234 }
235
239 public function testObjId(): void
240 {
241 $request = $this->getRequest(
242 [
243 "obj_id" => "15"
244 ],
245 [
246 ]
247 );
248
249 $this->assertEquals(
250 15,
251 $request->getObjId()
252 );
253 }
254}
Test clipboard repository.
getRequest(array $get, array $post)
testPostBeatsGet()
Test that post values overwrite get values.
$post
Definition: ltitoken.php:46
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.