ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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.

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

34  : NoUIFactory
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)
+ Here is the call graph for this function:

◆ testAttributes()

PaginationTest::testAttributes ( )

Definition at line 70 of file PaginationTest.php.

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

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  }
+ Here is the call graph for this function:

◆ testConstruction()

PaginationTest::testConstruction ( )

Definition at line 62 of file PaginationTest.php.

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

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  }
+ Here is the call graph for this function:

◆ testGetRangeOnNull()

PaginationTest::testGetRangeOnNull ( )

Definition at line 278 of file PaginationTest.php.

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

278  : void
279  {
280  $page_size = 0;
281  $current_page = 1;
282  $range = null;
283 
284  $pagination = $this->getFactory()->pagination()
285  ->withCurrentPage($current_page)
286  ->withPageSize($page_size);
287 
288  $this->assertNull($pagination->getRange());
289  $this->assertEquals($range, $pagination->getRange());
290  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ testRenderDropdown()

PaginationTest::testRenderDropdown ( )

Definition at line 240 of file PaginationTest.php.

References ILIAS\Repository\button(), ILIAS\UI\examples\Input\Field\Checkbox\disabled(), and getFactory().

240  : void
241  {
242  $p = $this->getFactory()->pagination()
243  ->withTotalEntries(3)
244  ->withPageSize(1)
245  ->withDropdownAt(1);
246 
247  $expected_html = <<<EOT
248 <div class="il-viewcontrol-pagination l-bar__element">
249  <button class="btn btn-default" data-action="?pagination_offset=0" disabled="disabled">
250  <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
251  </button>
252  <div class="dropdown" id="id_4">
253  <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>
254  <ul id="id_4_menu" class="dropdown-menu">
255  <li>
256  <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=0" id="id_1">1</button>
257  </li>
258  <li>
259  <button class="btn btn-link" data-action="?pagination_offset=1" id="id_2">2</button>
260  </li>
261  <li>
262  <button class="btn btn-link" data-action="?pagination_offset=2" id="id_3">3</button>
263  </li>
264  </ul>
265  </div>
266  <button class="btn btn-default" data-action="?pagination_offset=1" id="id_5">
267  <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
268  </button>
269 </div>
270 EOT;
271  $html = $this->getDefaultRenderer()->render($p);
272  $this->assertEquals(
273  $this->brutallyTrimHTML($expected_html),
274  $this->brutallyTrimHTML($html)
275  );
276  }
button(string $caption, string $cmd)
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
+ Here is the call graph for this function:

◆ testRenderLimited()

PaginationTest::testRenderLimited ( )

Definition at line 151 of file PaginationTest.php.

References ILIAS\Repository\button(), ILIAS\UI\examples\Input\Field\Checkbox\disabled(), and getFactory().

151  : void
152  {
153  $p = $this->getFactory()->pagination()
154  ->withTotalEntries(3)
155  ->withPageSize(1)
156  ->withMaxPaginationButtons(1);
157 
158  //one entry,
159  //browse-left disabled
160  //boundary-button right
161  $expected_html = <<<EOT
162 <div class="il-viewcontrol-pagination l-bar__element">
163  <button class="btn btn-default" data-action="?pagination_offset=0" disabled="disabled">
164  <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
165  </button>
166  <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=0" id="id_1">1</button>
167  <span class="last"><button class="btn btn-link" data-action="?pagination_offset=2" id="id_2">3</button></span>
168  <button class="btn btn-default" data-action="?pagination_offset=1" id="id_3">
169  <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
170  </button>
171 </div>
172 EOT;
173  $html = $this->getDefaultRenderer()->render($p);
174  $this->assertEquals(
175  $this->brutallyTrimHTML($expected_html),
176  $this->brutallyTrimHTML($html)
177  );
178  }
button(string $caption, string $cmd)
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
+ Here is the call graph for this function:

◆ testRenderLimitedWithCurrentPage()

PaginationTest::testRenderLimitedWithCurrentPage ( )

Definition at line 180 of file PaginationTest.php.

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

180  : void
181  {
182  $p = $this->getFactory()->pagination()
183  ->withTotalEntries(3)
184  ->withPageSize(1)
185  ->withMaxPaginationButtons(1)
186  ->withCurrentPage(1);
187 
188  //one entry,
189  //both rockers enabled
190  //both boundary-buttons
191  $expected_html = <<<EOT
192 <div class="il-viewcontrol-pagination l-bar__element">
193  <button class="btn btn-default" data-action="?pagination_offset=0" id="id_4">
194  <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
195  </button><span class="first"><button class="btn btn-link" data-action="?pagination_offset=0" id="id_2">1</button></span>
196  <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=1" id="id_1">2</button>
197  <span class="last"><button class="btn btn-link" data-action="?pagination_offset=2" id="id_3">3</button></span>
198  <button class="btn btn-default" data-action="?pagination_offset=2" id="id_5">
199  <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
200  </button>
201 </div>
202 EOT;
203  $html = $this->getDefaultRenderer()->render($p);
204  $this->assertHTMLEquals(
205  $this->brutallyTrimHTML($expected_html),
206  $this->brutallyTrimHTML($html)
207  );
208  }
button(string $caption, string $cmd)
+ Here is the call graph for this function:

◆ testRenderLimitedWithCurrentPage2()

PaginationTest::testRenderLimitedWithCurrentPage2 ( )

Definition at line 210 of file PaginationTest.php.

References ILIAS\Repository\button(), ILIAS\UI\examples\Input\Field\Checkbox\disabled(), and getFactory().

210  : void
211  {
212  $p = $this->getFactory()->pagination()
213  ->withTotalEntries(3)
214  ->withPageSize(1)
215  ->withMaxPaginationButtons(1)
216  ->withCurrentPage(2);
217 
218  //one entry,
219  //browse-right disabled
220  //boundary-button left only
221  $expected_html = <<<EOT
222 <div class="il-viewcontrol-pagination l-bar__element">
223  <button class="btn btn-default" data-action="?pagination_offset=1" id="id_3">
224  <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
225  </button>
226  <span class="first"><button class="btn btn-link" data-action="?pagination_offset=0" id="id_2">1</button></span>
227  <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=2" id="id_1">3</button>
228  <button class="btn btn-default" data-action="?pagination_offset=3" disabled="disabled">
229  <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
230  </button>
231 </div>
232 EOT;
233  $html = $this->getDefaultRenderer()->render($p);
234  $this->assertEquals(
235  $this->brutallyTrimHTML($expected_html),
236  $this->brutallyTrimHTML($html)
237  );
238  }
button(string $caption, string $cmd)
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
+ Here is the call graph for this function:

◆ testRenderWithCurrentPage()

PaginationTest::testRenderWithCurrentPage ( )

Definition at line 122 of file PaginationTest.php.

References ILIAS\Repository\button(), ILIAS\UI\examples\Input\Field\Checkbox\disabled(), and getFactory().

122  : void
123  {
124  $p = $this->getFactory()->pagination()
125  ->withTotalEntries(2)
126  ->withPageSize(1)
127  ->withCurrentPage(1);
128 
129  //two entries, second one inactive
130  //browse-right disabled
131  $expected_html = <<<EOT
132 <div class="il-viewcontrol-pagination l-bar__element">
133  <button class="btn btn-default" data-action="?pagination_offset=0" id="id_3">
134  <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
135  </button>
136  <button class="btn btn-link" data-action="?pagination_offset=0" id="id_1">1</button>
137  <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=1" id="id_2">2</button>
138  <button class="btn btn-default" data-action="?pagination_offset=2" disabled="disabled">
139  <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
140  </button>
141 </div>
142 EOT;
143 
144  $html = $this->getDefaultRenderer()->render($p);
145  $this->assertHTMLEquals(
146  $this->brutallyTrimHTML($expected_html),
147  $this->brutallyTrimHTML($html)
148  );
149  }
button(string $caption, string $cmd)
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
+ Here is the call graph for this function:

◆ testRenderWithOnePageOnly()

PaginationTest::testRenderWithOnePageOnly ( )

Definition at line 292 of file PaginationTest.php.

References getFactory().

292  : void
293  {
294  $p = $this->getFactory()->pagination()
295  ->withTotalEntries(30)
296  ->withPageSize(30);
297  $expected_html = '';
298  $html = $this->getDefaultRenderer()->render($p);
299  $this->assertEquals($expected_html, $html);
300  }
+ Here is the call graph for this function:

◆ testViewControlPaginationRenderUnlimited()

PaginationTest::testViewControlPaginationRenderUnlimited ( )

Definition at line 97 of file PaginationTest.php.

References ILIAS\Repository\button(), ILIAS\UI\examples\Input\Field\Checkbox\disabled(), and getFactory().

97  : void
98  {
99  $p = $this->getFactory()->pagination()
100  ->withTotalEntries(2)
101  ->withPageSize(1);
102 
103  //two entries, first one inactive
104  //browse-left disabled
105  $expected_html = <<<EOT
106 <div class="il-viewcontrol-pagination l-bar__element">
107  <button class="btn btn-default" data-action="?pagination_offset=0" disabled="disabled">
108  <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
109  </button>
110  <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=0" id="id_1">1</button>
111  <button class="btn btn-link" data-action="?pagination_offset=1" id="id_2">2</button>
112  <button class="btn btn-default" data-action="?pagination_offset=1" id="id_3">
113  <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
114  </button>
115 </div>
116 EOT;
117 
118  $html = $this->getDefaultRenderer()->render($p);
119  $this->assertEquals($this->brutallyTrimHTML($expected_html), $this->brutallyTrimHTML($html));
120  }
button(string $caption, string $cmd)
disabled()
description: > Example showing how to plug a disabled checkbox into a form
Definition: disabled.php:32
+ Here is the call graph for this function:

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