ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SplEditingGUIRequestTest.php
Go to the documentation of this file.
1<?php
2
19use PHPUnit\Framework\TestCase;
20
26class SplEditingGUIRequestTest extends TestCase
27{
28 protected function tearDown(): void
29 {
30 }
31
32 protected function getRequest(array $get, array $post): \ILIAS\SurveyQuestionPool\Editing\EditingGUIRequest
33 {
34 $http_mock = $this->createMock(ILIAS\HTTP\Services::class);
35 $lng_mock = $this->createMock(ilLanguage::class);
36 $data = new \ILIAS\Data\Factory();
37 $refinery = new \ILIAS\Refinery\Factory($data, $lng_mock);
38 return new \ILIAS\SurveyQuestionPool\Editing\EditingGUIRequest(
39 $http_mock,
41 $get,
42 $post
43 );
44 }
45
46 public function testRefId(): void
47 {
48 $request = $this->getRequest(
49 [
50 "ref_id" => 102
51 ],
52 []
53 );
54
55 $this->assertEquals(
56 102,
57 $request->getRefId()
58 );
59 }
60
61 public function testQuestionId(): void
62 {
63 $request = $this->getRequest(
64 [
65 "q_id" => 33
66 ],
67 []
68 );
69
70 $this->assertEquals(
71 33,
72 $request->getQuestionId()
73 );
74 }
75
76 public function testQuestionIds(): void
77 {
78 $request = $this->getRequest(
79 [
80
81 ],
82 [
83 "q_id" => ["13", "15", "19"]
84 ]
85 );
86
87 $this->assertEquals(
88 [13, 15, 19],
89 $request->getQuestionIds()
90 );
91 }
92
93 public function testPreview(): void
94 {
95 $request = $this->getRequest(
96 [
97 "preview" => 1
98 ],
99 []
100 );
101
102 $this->assertEquals(
103 1,
104 $request->getPreview()
105 );
106 }
107
108 public function testSelectedQuestionTypes(): void
109 {
110 $request = $this->getRequest(
111 [
112 "sel_question_types" => "Metric"
113 ],
114 []
115 );
116
117 $this->assertEquals(
118 "Metric",
119 $request->getSelectedQuestionTypes()
120 );
121 }
122
123 public function testSort(): void
124 {
125 $request = $this->getRequest(
126 [
127
128 ],
129 [
130 "sort" => [
131 "a" => "a1",
132 "b" => "b1",
133 "c" => "c1",
134 ]
135 ]
136 );
137
138 $this->assertEquals(
139 [
140 "a" => "a1",
141 "b" => "b1",
142 "c" => "c1",
143 ],
144 $request->getSort()
145 );
146 }
147
148}
Test editing request class.
getRequest(array $get, array $post)
$post
Definition: ltitoken.php:46
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.