ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PaginationTest Class Reference

Test on Pagination view control. More...

+ Inheritance diagram for PaginationTest:
+ Collaboration diagram for PaginationTest:

Public Member Functions

 getUIFactory ()
 
 testConstruction ()
 
 testAttributes ()
 
 testViewControlPaginationRenderUnlimited ()
 
 testRenderWithCurrentPage ()
 
 testRenderLimited ()
 
 testRenderLimitedWithCurrentPage ()
 
 testRenderLimitedWithCurrentPage2 ()
 
 testRenderDropdown ()
 
 testGetRangeOnNull ()
 
 testRenderWithOnePageOnly ()
 

Private Member Functions

 getFactory ()
 

Detailed Description

Test on Pagination view control.

Definition at line 32 of file PaginationTest.php.

Member Function Documentation

◆ getFactory()

◆ getUIFactory()

PaginationTest::getUIFactory ( )

Definition at line 34 of file PaginationTest.php.

35 {
36 return new class () extends NoUIFactory {
37 public function symbol(): IC\Symbol\Factory
38 {
39 return new IC\Symbol\Factory(
40 new IC\Symbol\Icon\Factory(),
41 new IC\Symbol\Glyph\Factory(),
42 new IC\Symbol\Avatar\Factory()
43 );
44 }
45 public function button(): IC\Button\Factory
46 {
47 return new IC\Button\Factory();
48 }
49 public function dropdown(): IC\Dropdown\Factory
50 {
51 return new IC\Dropdown\Factory();
52 }
53 };
54 }
button(string $caption, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21

References ILIAS\Repository\button(), and ILIAS\Repository\symbol().

+ Here is the call graph for this function:

◆ testAttributes()

PaginationTest::testAttributes ( )

Definition at line 70 of file PaginationTest.php.

70 : void
71 {
72 $total_entries = 111;
73 $page_size = 100;
74 $current_page = 1;
75 //$select_signal;
76 $target_url = 'http://testurl';
77 $parameter_name = "param_name";
78 $max_page_options = 10;
79
80 $f = $this->getFactory();
81 $p = $f->pagination()
82 ->withTargetURL($target_url, $parameter_name)
83 ->withTotalEntries($total_entries)
84 ->withPageSize($page_size)
85 ->withCurrentPage($current_page)
86 ->withMaxPaginationButtons($max_page_options)
87 ;
88
89 $this->assertEquals($target_url, $p->getTargetURL());
90 $this->assertEquals($parameter_name, $p->getParameterName());
91 $this->assertEquals($page_size, $p->getPageSize());
92 $this->assertEquals($current_page, $p->getCurrentPage());
93 $this->assertEquals($max_page_options, $p->getMaxPaginationButtons());
94 $this->assertEquals(2, $p->getNumberOfPages());
95 }

References Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ testConstruction()

PaginationTest::testConstruction ( )

Definition at line 62 of file PaginationTest.php.

62 : void
63 {
64 $f = $this->getFactory();
65 $pagination = $f->pagination();
66 $this->assertInstanceOf("ILIAS\\UI\\Component\\ViewControl\\Pagination", $pagination);
67 $this->assertInstanceOf("ILIAS\\UI\\Component\\Signal", $pagination->getInternalSignal());
68 }

References Vendor\Package\$f, and getFactory().

+ Here is the call graph for this function:

◆ testGetRangeOnNull()

PaginationTest::testGetRangeOnNull ( )

Definition at line 263 of file PaginationTest.php.

263 : void
264 {
265 $page_size = 0;
266 $current_page = 1;
267 $range = null;
268
269 $pagination = $this->getFactory()->pagination()
270 ->withCurrentPage($current_page)
271 ->withPageSize($page_size);
272
273 $this->assertNull($pagination->getRange());
274 $this->assertEquals($range, $pagination->getRange());
275 }

References ILIAS\UI\Implementation\Component\Table\$range, and getFactory().

+ Here is the call graph for this function:

◆ testRenderDropdown()

PaginationTest::testRenderDropdown ( )

Definition at line 228 of file PaginationTest.php.

228 : void
229 {
230 $p = $this->getFactory()->pagination()
231 ->withTotalEntries(3)
232 ->withPageSize(1)
233 ->withDropdownAt(1);
234
235 $expected_html = <<<EOT
236<div class="il-viewcontrol-pagination l-bar__element">
237 <div class="dropdown" id="id_4">
238 <button class="btn btn-default dropdown-toggle" type="button" aria-haspopup="true" aria-expanded="false" aria-controls="id_4_menu">pagination_label_x_of_y<span class="caret"></span></button>
239 <ul id="id_4_menu" class="dropdown-menu">
240 <li>
241 <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=0" id="id_1">1</button>
242 </li>
243 <li>
244 <button class="btn btn-link" data-action="?pagination_offset=1" id="id_2">2</button>
245 </li>
246 <li>
247 <button class="btn btn-link" data-action="?pagination_offset=2" id="id_3">3</button>
248 </li>
249 </ul>
250 </div>
251 <button class="btn btn-default" data-action="?pagination_offset=1" id="id_5">
252 <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
253 </button>
254</div>
255EOT;
256 $html = $this->getDefaultRenderer()->render($p);
257 $this->assertEquals(
258 $this->brutallyTrimHTML($expected_html),
259 $this->brutallyTrimHTML($html)
260 );
261 }

References ILIAS\Repository\button(), and getFactory().

+ Here is the call graph for this function:

◆ testRenderLimited()

PaginationTest::testRenderLimited ( )

Definition at line 145 of file PaginationTest.php.

145 : void
146 {
147 $p = $this->getFactory()->pagination()
148 ->withTotalEntries(3)
149 ->withPageSize(1)
150 ->withMaxPaginationButtons(1);
151
152 //one entry,
153 //browse-left not rendered
154 //boundary-button right
155 $expected_html = <<<EOT
156<div class="il-viewcontrol-pagination l-bar__element">
157 <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=0" id="id_1">1</button>
158 <span class="last"><button class="btn btn-link" data-action="?pagination_offset=2" id="id_2">3</button></span>
159 <button class="btn btn-default" data-action="?pagination_offset=1" id="id_3">
160 <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
161 </button>
162</div>
163EOT;
164 $html = $this->getDefaultRenderer()->render($p);
165 $this->assertEquals(
166 $this->brutallyTrimHTML($expected_html),
167 $this->brutallyTrimHTML($html)
168 );
169 }

References ILIAS\Repository\button(), and getFactory().

+ Here is the call graph for this function:

◆ testRenderLimitedWithCurrentPage()

PaginationTest::testRenderLimitedWithCurrentPage ( )

Definition at line 171 of file PaginationTest.php.

171 : void
172 {
173 $p = $this->getFactory()->pagination()
174 ->withTotalEntries(3)
175 ->withPageSize(1)
176 ->withMaxPaginationButtons(1)
177 ->withCurrentPage(1);
178
179 //one entry,
180 //both rockers enabled
181 //both boundary-buttons
182 $expected_html = <<<EOT
183<div class="il-viewcontrol-pagination l-bar__element">
184 <button class="btn btn-default" data-action="?pagination_offset=0" id="id_4">
185 <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
186 </button><span class="first"><button class="btn btn-link" data-action="?pagination_offset=0" id="id_2">1</button></span>
187 <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=1" id="id_1">2</button>
188 <span class="last"><button class="btn btn-link" data-action="?pagination_offset=2" id="id_3">3</button></span>
189 <button class="btn btn-default" data-action="?pagination_offset=2" id="id_5">
190 <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
191 </button>
192</div>
193EOT;
194 $html = $this->getDefaultRenderer()->render($p);
195 $this->assertHTMLEquals(
196 $this->brutallyTrimHTML($expected_html),
197 $this->brutallyTrimHTML($html)
198 );
199 }

References ILIAS\Repository\button(), and getFactory().

+ Here is the call graph for this function:

◆ testRenderLimitedWithCurrentPage2()

PaginationTest::testRenderLimitedWithCurrentPage2 ( )

Definition at line 201 of file PaginationTest.php.

201 : void
202 {
203 $p = $this->getFactory()->pagination()
204 ->withTotalEntries(3)
205 ->withPageSize(1)
206 ->withMaxPaginationButtons(1)
207 ->withCurrentPage(2);
208
209 //one entry,
210 //browse-right not rendered
211 //boundary-button left only
212 $expected_html = <<<EOT
213<div class="il-viewcontrol-pagination l-bar__element">
214 <button class="btn btn-default" data-action="?pagination_offset=1" id="id_3">
215 <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
216 </button>
217 <span class="first"><button class="btn btn-link" data-action="?pagination_offset=0" id="id_2">1</button></span>
218 <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=2" id="id_1">3</button>
219</div>
220EOT;
221 $html = $this->getDefaultRenderer()->render($p);
222 $this->assertEquals(
223 $this->brutallyTrimHTML($expected_html),
224 $this->brutallyTrimHTML($html)
225 );
226 }

References ILIAS\Repository\button(), and getFactory().

+ Here is the call graph for this function:

◆ testRenderWithCurrentPage()

PaginationTest::testRenderWithCurrentPage ( )

Definition at line 119 of file PaginationTest.php.

119 : void
120 {
121 $p = $this->getFactory()->pagination()
122 ->withTotalEntries(2)
123 ->withPageSize(1)
124 ->withCurrentPage(1);
125
126 //two entries, second one inactive
127 //browse-right not rendered
128 $expected_html = <<<EOT
129<div class="il-viewcontrol-pagination l-bar__element">
130 <button class="btn btn-default" data-action="?pagination_offset=0" id="id_3">
131 <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
132 </button>
133 <button class="btn btn-link" data-action="?pagination_offset=0" id="id_1">1</button>
134 <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=1" id="id_2">2</button>
135</div>
136EOT;
137
138 $html = $this->getDefaultRenderer()->render($p);
139 $this->assertHTMLEquals(
140 $this->brutallyTrimHTML($expected_html),
141 $this->brutallyTrimHTML($html)
142 );
143 }

References ILIAS\Repository\button(), and getFactory().

+ Here is the call graph for this function:

◆ testRenderWithOnePageOnly()

PaginationTest::testRenderWithOnePageOnly ( )

Definition at line 277 of file PaginationTest.php.

277 : void
278 {
279 $p = $this->getFactory()->pagination()
280 ->withTotalEntries(30)
281 ->withPageSize(30);
282 $expected_html = '';
283 $html = $this->getDefaultRenderer()->render($p);
284 $this->assertEquals($expected_html, $html);
285 }

References getFactory().

+ Here is the call graph for this function:

◆ testViewControlPaginationRenderUnlimited()

PaginationTest::testViewControlPaginationRenderUnlimited ( )

Definition at line 97 of file PaginationTest.php.

97 : void
98 {
99 $p = $this->getFactory()->pagination()
100 ->withTotalEntries(2)
101 ->withPageSize(1);
102
103 //two entries, first one inactive
104 //browse-left not rendered
105 $expected_html = <<<EOT
106<div class="il-viewcontrol-pagination l-bar__element">
107 <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=0" id="id_1">1</button>
108 <button class="btn btn-link" data-action="?pagination_offset=1" id="id_2">2</button>
109 <button class="btn btn-default" data-action="?pagination_offset=1" id="id_3">
110 <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
111 </button>
112</div>
113EOT;
114
115 $html = $this->getDefaultRenderer()->render($p);
116 $this->assertEquals($this->brutallyTrimHTML($expected_html), $this->brutallyTrimHTML($html));
117 }

References ILIAS\Repository\button(), and getFactory().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: