ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
LinkStandardGUIRequestTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace IntLink;
4 
6 use ILIAS;
7 use ilLanguage;
8 
12 class LinkStandardGUIRequestTest extends TestCase
13 {
14  protected function tearDown(): void
15  {
16  }
17 
18  protected function getRequest(array $get, array $post): \ILIAS\COPage\IntLink\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\COPage\IntLink\StandardGUIRequest(
25  $http_mock,
26  $refinery,
27  $get,
28  $post
29  );
30  }
31 
32  public function testSelectedId(): void
33  {
34  $request = $this->getRequest(
35  [
36  "sel_id" => "123"
37  ],
38  [
39  ]
40  );
41 
42  $this->assertEquals(
43  123,
44  $request->getSelectedId()
45  );
46  }
47 
48  public function testDo(): void
49  {
50  $request = $this->getRequest(
51  [
52  "do" => "set"
53  ],
54  [
55  ]
56  );
57 
58  $this->assertEquals(
59  "set",
60  $request->getDo()
61  );
62  }
63 
64  public function testMediaPoolFolder(): void
65  {
66  $request = $this->getRequest(
67  [
68  "mep_fold" => "14"
69  ],
70  [
71  ]
72  );
73 
74  $this->assertEquals(
75  14,
76  $request->getMediaPoolFolder()
77  );
78  }
79 
80  public function testLinkType(): void
81  {
82  $request = $this->getRequest(
83  [
84  "link_type" => "mytype"
85  ],
86  [
87  ]
88  );
89 
90  $this->assertEquals(
91  "mytype",
92  $request->getLinkType()
93  );
94  }
95 
96  public function testLinkParentObjId(): void
97  {
98  $request = $this->getRequest(
99  [
100  "link_par_obj_id" => "13"
101  ],
102  [
103  ]
104  );
105 
106  $this->assertEquals(
107  13,
108  $request->getLinkParentObjId()
109  );
110  }
111 
112  public function testLinkParentFolderId(): void
113  {
114  $request = $this->getRequest(
115  [
116  "link_par_fold_id" => "18"
117  ],
118  [
119  ]
120  );
121 
122  $this->assertEquals(
123  18,
124  $request->getLinkParentFolderId()
125  );
126  }
127 
128  public function testLinkParentRefId(): void
129  {
130  $request = $this->getRequest(
131  [
132  "link_par_ref_id" => "22"
133  ],
134  [
135  ]
136  );
137 
138  $this->assertEquals(
139  22,
140  $request->getLinkParentRefId()
141  );
142  }
143 
144  public function testUserSearchString(): void
145  {
146  $request = $this->getRequest(
147  [
148  ],
149  [
150  "usr_search_str" => "term"
151  ]
152  );
153 
154  $this->assertEquals(
155  "term",
156  $request->getUserSearchStr()
157  );
158  }
159 }
Interface Observer Contains several chained tasks and infos about them.
$post
Definition: ltitoken.php:46