ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
AdminGUIRequestTest.php
Go to the documentation of this file.
1 <?php
2 
20 
26 class AdminGUIRequestTest extends TestCase
27 {
28  //protected $backupGlobals = false;
29 
30  protected function setUp(): void
31  {
32  parent::setUp();
33  }
34 
35  protected function tearDown(): void
36  {
37  }
38 
39  protected function getRequest(array $get, array $post): \ILIAS\Administration\AdminGUIRequest
40  {
41  $http_mock = $this->createMock(ILIAS\HTTP\Services::class);
42  $lng_mock = $this->createMock(ilLanguage::class);
43  $data = new \ILIAS\Data\Factory();
44  $refinery = new \ILIAS\Refinery\Factory($data, $lng_mock);
45  return new \ILIAS\Administration\AdminGUIRequest(
46  $http_mock,
47  $refinery,
48  $get,
49  $post
50  );
51  }
52 
56  public function testRefId(): void
57  {
58  $request = $this->getRequest(
59  [
60  "ref_id" => "5"
61  ],
62  []
63  );
64 
65  $this->assertEquals(
66  5,
67  $request->getRefId()
68  );
69  }
70 
74  public function testNoRefId(): void
75  {
76  $request = $this->getRequest(
77  [
78  ],
79  []
80  );
81 
82  $this->assertEquals(
83  0,
84  $request->getRefId()
85  );
86  }
87 
91  public function testAdminMode(): void
92  {
93  $request = $this->getRequest(
94  [
95  "admin_mode" => "repository"
96  ],
97  []
98  );
99 
100  $this->assertEquals(
101  "repository",
102  $request->getAdminMode()
103  );
104  }
105 
109  public function testSelectedIds(): void
110  {
111  $request = $this->getRequest(
112  [
113  ],
114  [
115  "id" => ["1", "2", "3"]
116  ]
117  );
118 
119  $this->assertEquals(
120  [1,2,3],
121  $request->getSelectedIds()
122  );
123  }
124 
128  public function testNewType(): void
129  {
130  $request = $this->getRequest(
131  [
132  "new_type" => "usr"
133  ],
134  []
135  );
136 
137  $this->assertEquals(
138  "usr",
139  $request->getNewType()
140  );
141  }
142 
146  public function testUserId(): void
147  {
148  $request = $this->getRequest(
149  [
150  "jmpToUser" => "15"
151  ],
152  []
153  );
154 
155  $this->assertEquals(
156  15,
157  $request->getJumpToUserId()
158  );
159  }
160 
164  public function testPluginId(): void
165  {
166  $request = $this->getRequest(
167  [
168  "plugin_id" => "xyz"
169  ],
170  []
171  );
172 
173  $this->assertEquals(
174  "xyz",
175  $request->getPluginId()
176  );
177  }
178 }
testSelectedIds()
Test selected ids.
Class ChatMainBarProvider .
testPluginId()
Test plugin id.
testNewType()
Test new type.
testAdminMode()
Test admin mode.
getRequest(array $get, array $post)
Test administration request class.
testUserId()
Test user id.
testNoRefId()
Test no ref id.
$post
Definition: ltitoken.php:49
Refinery Factory $refinery