ILIAS  release_8 Revision v8.24
CatStandardGUIRequestTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5use PHPUnit\Framework\TestCase;
6
12class CatStandardGUIRequestTest extends TestCase
13{
14 protected function tearDown(): void
15 {
16 }
17
18 protected function getRequest(array $get, array $post): \ILIAS\Category\StandardGUIRequest
19 {
20 $http_mock = $this->createMock(ILIAS\HTTP\Services::class);
21 $lng_mock = $this->createMock(ilLanguage::class);
22 $data = new \ILIAS\Data\Factory();
23 $refinery = new \ILIAS\Refinery\Factory($data, $lng_mock);
24 return new \ILIAS\Category\StandardGUIRequest(
25 $http_mock,
27 $get,
28 $post
29 );
30 }
31
35 public function testRefId(): void
36 {
37 $request = $this->getRequest(
38 [
39 "ref_id" => "5"
40 ],
41 []
42 );
43
44 $this->assertEquals(
45 5,
46 $request->getRefId()
47 );
48 }
49
53 public function testNoRefId(): void
54 {
55 $request = $this->getRequest(
56 [
57 ],
58 []
59 );
60
61 $this->assertEquals(
62 0,
63 $request->getRefId()
64 );
65 }
66
70 public function testBaseClass(): void
71 {
72 $request = $this->getRequest(
73 [
74 "baseClass" => "myClass"
75 ],
76 []
77 );
78
79 $this->assertEquals(
80 "myClass",
81 $request->getBaseClass()
82 );
83 }
84
88 public function testCmdClass(): void
89 {
90 $request = $this->getRequest(
91 [
92 "cmdClass" => "myClass"
93 ],
94 []
95 );
96
97 $this->assertEquals(
98 "myClass",
99 $request->getCmdClass()
100 );
101 }
102
106 public function testTerm(): void
107 {
108 $request = $this->getRequest(
109 [
110 "term" => "my_term"
111 ],
112 []
113 );
114
115 $this->assertEquals(
116 "my_term",
117 $request->getTerm()
118 );
119 }
120
124 public function testTermByPost(): void
125 {
126 $request = $this->getRequest(
127 [
128 ],
129 [
130 "term" => "my_term"
131 ]
132 );
133
134 $this->assertEquals(
135 "my_term",
136 $request->getTerm()
137 );
138 }
139
143 public function testPostBeatsGet(): void
144 {
145 $request = $this->getRequest(
146 [
147 "term" => "one"
148 ],
149 [
150 "term" => "two"
151 ]
152 );
153
154 $this->assertEquals(
155 "two",
156 $request->getTerm()
157 );
158 }
159
163 public function testFetchAll(): void
164 {
165 $request = $this->getRequest(
166 [
167 "fetchall" => "1"
168 ],
169 []
170 );
171
172 $this->assertEquals(
173 1,
174 $request->getFetchAll()
175 );
176 }
177
181 public function testRoleIds(): void
182 {
183 $request = $this->getRequest(
184 [
185 ],
186 [
187 "role_ids" => [
188 "6", "7", "9"
189 ]
190 ]
191 );
192
193 $this->assertEquals(
194 [6,7,9],
195 $request->getRoleIds()
196 );
197 }
198
202 public function testUserIds(): void
203 {
204 $request = $this->getRequest(
205 [
206 ],
207 [
208 "user_ids" => [
209 "6", "7", "10"
210 ]
211 ]
212 );
213
214 $this->assertEquals(
215 [6,7,10],
216 $request->getUserIds()
217 );
218 }
219
223 public function testObjId(): void
224 {
225 $request = $this->getRequest(
226 [
227 "obj_id" => "15"
228 ],
229 [
230 ]
231 );
232
233 $this->assertEquals(
234 15,
235 $request->getObjId()
236 );
237 }
238}
Test clipboard repository.
getRequest(array $get, array $post)
testPostBeatsGet()
Test that post values overwrite get values.
$post
Definition: ltitoken.php:49
Refinery Factory $refinery
Class ChatMainBarProvider \MainMenu\Provider.