ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
PaginationTest Class Reference

Test on Pagination view control. More...

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

Public Member Functions

 getUIFactory ()
 
 testConstruction ()
 
 testAttributes ()
 
 testRenderUnlimited ()
 
 testRenderWithCurrentPage ()
 
 testRenderLimited ()
 
 testRenderLimitedWithCurrentPage ()
 
 testRenderLimitedWithCurrentPage2 ()
 
 testRenderDropdown ()
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null)
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML ($html)
 
 assertHTMLEquals ($expected_html_as_string, $html_as_string)
 

Private Member Functions

 getFactory ()
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML ($html)
 A more radical version of normalizeHTML. More...
 

Detailed Description

Test on Pagination view control.

Definition at line 14 of file PaginationTest.php.

Member Function Documentation

◆ getFactory()

PaginationTest::getFactory ( )
private

Definition at line 39 of file PaginationTest.php.

Referenced by testAttributes(), testConstruction(), testRenderDropdown(), testRenderLimited(), testRenderLimitedWithCurrentPage(), testRenderLimitedWithCurrentPage2(), testRenderUnlimited(), and testRenderWithCurrentPage().

40  {
41  $sg = new SignalGenerator();
42  return new \ILIAS\UI\Implementation\Component\ViewControl\Factory($sg);
43  }
+ Here is the caller graph for this function:

◆ getUIFactory()

PaginationTest::getUIFactory ( )

Definition at line 16 of file PaginationTest.php.

References $factory.

17  {
18  $factory = new class extends NoUIFactory {
19  public function symbol() : C\Symbol\Factory
20  {
21  return new IC\Symbol\Factory(
22  new IC\Symbol\Icon\Factory(),
23  new IC\Symbol\Glyph\Factory(),
24  new IC\Symbol\Avatar\Factory()
25  );
26  }
27  public function button()
28  {
29  return new IC\Button\Factory(new SignalGenerator());
30  }
31  public function dropdown()
32  {
33  return new IC\Dropdown\Factory();
34  }
35  };
36  return $factory;
37  }
$factory
Definition: metadata.php:58

◆ testAttributes()

PaginationTest::testAttributes ( )

Definition at line 59 of file PaginationTest.php.

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

60  {
61  $total_entries = 111;
62  $page_size = 100;
63  $current_page = 1;
64  //$select_signal;
65  $target_url = 'http://testurl';
66  $parameter_name = "param_name";
67  $max_page_options = 10;
68 
69  $f = $this->getFactory();
70  $p = $f->pagination()
71  ->withTargetURL($target_url, $parameter_name)
72  ->withTotalEntries($total_entries)
73  ->withPageSize($page_size)
74  ->withCurrentPage($current_page)
75  ->withMaxPaginationButtons($max_page_options)
76  ;
77 
78  $this->assertEquals($target_url, $p->getTargetURL());
79  $this->assertEquals($parameter_name, $p->getParameterName());
80  $this->assertEquals($page_size, $p->getPageSize());
81  $this->assertEquals($current_page, $p->getCurrentPage());
82  $this->assertEquals($max_page_options, $p->getMaxPaginationButtons());
83  $this->assertEquals(2, $p->getNumberOfPages());
84  $this->assertEquals(11, $p->getPageLength());
85  }
+ Here is the call graph for this function:

◆ testConstruction()

PaginationTest::testConstruction ( )

Definition at line 45 of file PaginationTest.php.

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

46  {
47  $f = $this->getFactory();
48  $pagination = $f->pagination();
49  $this->assertInstanceOf(
50  "ILIAS\\UI\\Component\\ViewControl\\Pagination",
51  $pagination
52  );
53  $this->assertInstanceOf(
54  "ILIAS\\UI\\Component\\Signal",
55  $pagination->getInternalSignal()
56  );
57  }
+ Here is the call graph for this function:

◆ testRenderDropdown()

PaginationTest::testRenderDropdown ( )

Definition at line 262 of file PaginationTest.php.

References ILIAS_UI_TestBase\assertHTMLEquals(), disabled(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

263  {
264  $p = $this->getFactory()->pagination()
265  ->withTotalEntries(3)
266  ->withPageSize(1)
267  ->withDropdownAt(1);
268 
269  $expected_html = <<<EOT
270 <div class="il-viewcontrol-pagination">
271  <span class="browse previous">
272  <a class="glyph disabled" aria-label="back" aria-disabled="true">
273  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
274  </a>
275  </span>
276 
277  <div class="dropdown">
278  <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">pagination_label_x_of_y <span class="caret"></span></button>
279  <ul class="dropdown-menu">
280  <li><button class="btn btn-link" data-action="?pagination_offset=0" disabled="disabled">1</button></li>
281  <li><button class="btn btn-link" data-action="?pagination_offset=1" id="id_1">2</button></li>
282  <li><button class="btn btn-link" data-action="?pagination_offset=2" id="id_2">3</button></li>
283  </ul>
284  </div>
285 
286  <span class="browse next">
287  <a class="glyph" href="?pagination_offset=1" aria-label="next">
288  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
289  </a>
290  </span>
291 </div>
292 EOT;
293  $html = $this->getDefaultRenderer()->render($p);
294  $this->assertHTMLEquals($expected_html, $html);
295  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:5
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ testRenderLimited()

PaginationTest::testRenderLimited ( )

Definition at line 150 of file PaginationTest.php.

References ILIAS_UI_TestBase\assertHTMLEquals(), disabled(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

151  {
152  $p = $this->getFactory()->pagination()
153  ->withTotalEntries(3)
154  ->withPageSize(1)
155  ->withMaxPaginationButtons(1);
156 
157  //one entry,
158  //browse-left disabled
159  //boundary-button right
160  $expected_html = <<<EOT
161 <div class="il-viewcontrol-pagination">
162  <span class="browse previous">
163  <a class="glyph disabled" aria-label="back" aria-disabled="true">
164  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
165  </a>
166  </span>
167 
168  <button class="btn btn-link" data-action="?pagination_offset=0" disabled="true">1</button>
169 
170  <span class="last">
171  <button class="btn btn-link" data-action="?pagination_offset=2" id="id_1">3</button>
172  </span>
173 
174  <span class="browse next">
175  <a class="glyph" href="?pagination_offset=1" aria-label="next">
176  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
177  </a>
178  </span>
179 </div>
180 EOT;
181  $html = $this->getDefaultRenderer()->render($p);
182  $this->assertHTMLEquals($expected_html, $html);
183  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:5
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ testRenderLimitedWithCurrentPage()

PaginationTest::testRenderLimitedWithCurrentPage ( )

Definition at line 185 of file PaginationTest.php.

References ILIAS_UI_TestBase\assertHTMLEquals(), disabled(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

186  {
187  $p = $this->getFactory()->pagination()
188  ->withTotalEntries(3)
189  ->withPageSize(1)
190  ->withMaxPaginationButtons(1)
191  ->withCurrentPage(1);
192 
193  //one entry,
194  //both rockers enabled
195  //both boundary-buttons
196  $expected_html = <<<EOT
197 <div class="il-viewcontrol-pagination">
198  <span class="browse previous">
199  <a class="glyph" href="?pagination_offset=0" aria-label="back">
200  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
201  </a>
202  </span>
203 
204  <span class="first">
205  <button class="btn btn-link" data-action="?pagination_offset=0" id="id_1">1</button>
206  </span>
207 
208  <button class="btn btn-link" data-action="?pagination_offset=1" disabled="true">2</button>
209 
210  <span class="last">
211  <button class="btn btn-link" data-action="?pagination_offset=2" id="id_2">3</button>
212  </span>
213 
214  <span class="browse next">
215  <a class="glyph" href="?pagination_offset=2" aria-label="next">
216  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
217  </a>
218  </span>
219 </div>
220 EOT;
221  $html = $this->getDefaultRenderer()->render($p);
222  $this->assertHTMLEquals($expected_html, $html);
223  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:5
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ testRenderLimitedWithCurrentPage2()

PaginationTest::testRenderLimitedWithCurrentPage2 ( )

Definition at line 225 of file PaginationTest.php.

References ILIAS_UI_TestBase\assertHTMLEquals(), disabled(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

226  {
227  $p = $this->getFactory()->pagination()
228  ->withTotalEntries(3)
229  ->withPageSize(1)
230  ->withMaxPaginationButtons(1)
231  ->withCurrentPage(2);
232 
233  //one entry,
234  //browse-right disabled
235  //boundary-button left only
236  $expected_html = <<<EOT
237 <div class="il-viewcontrol-pagination">
238  <span class="browse previous">
239  <a class="glyph" href="?pagination_offset=1" aria-label="back">
240  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
241  </a>
242  </span>
243  <span class="first">
244  <button class="btn btn-link" data-action="?pagination_offset=0" id="id_1">1</button>
245  </span>
246 
247  <button class="btn btn-link" data-action="?pagination_offset=2" disabled="disabled">3</button>
248 
249  <span class="browse next">
250  <a class="glyph disabled" aria-label="next" aria-disabled="true">
251  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
252  </a>
253  </span>
254 </div>
255 EOT;
256  $html = $this->getDefaultRenderer()->render($p);
257  $this->assertHTMLEquals($expected_html, $html);
258  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:5
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ testRenderUnlimited()

PaginationTest::testRenderUnlimited ( )

Definition at line 87 of file PaginationTest.php.

References ILIAS_UI_TestBase\assertHTMLEquals(), disabled(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

88  {
89  $p = $this->getFactory()->pagination()
90  ->withTotalEntries(2)
91  ->withPageSize(1);
92 
93  //two entries, first one inactive
94  //browse-left disabled
95  $expected_html = <<<EOT
96 <div class="il-viewcontrol-pagination">
97  <span class="browse previous">
98  <a class="glyph disabled" aria-label="back" aria-disabled="true">
99  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
100  </a>
101  </span>
102 
103  <button class="btn btn-link" data-action="?pagination_offset=0" disabled="true">1</button>
104  <button class="btn btn-link" data-action="?pagination_offset=1" id="id_1">2</button>
105 
106  <span class="browse next">
107  <a class="glyph" href="?pagination_offset=1" aria-label="next">
108  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
109  </a>
110  </span>
111 </div>
112 EOT;
113 
114  $html = $this->getDefaultRenderer()->render($p);
115  $this->assertHTMLEquals($expected_html, $html);
116  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:5
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

◆ testRenderWithCurrentPage()

PaginationTest::testRenderWithCurrentPage ( )

Definition at line 118 of file PaginationTest.php.

References ILIAS_UI_TestBase\assertHTMLEquals(), disabled(), ILIAS_UI_TestBase\getDefaultRenderer(), and getFactory().

119  {
120  $p = $this->getFactory()->pagination()
121  ->withTotalEntries(2)
122  ->withPageSize(1)
123  ->withCurrentPage(1);
124 
125  //two entries, second one inactive
126  //browse-right disabled
127  $expected_html = <<<EOT
128 <div class="il-viewcontrol-pagination">
129  <span class="browse previous">
130  <a class="glyph" href="?pagination_offset=0" aria-label="back">
131  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
132  </a>
133  </span>
134 
135  <button class="btn btn-link" data-action="?pagination_offset=0" id="id_1">1</button>
136  <button class="btn btn-link" data-action="?pagination_offset=1" disabled="true">2</button>
137 
138  <span class="browse next">
139  <a class="glyph disabled" aria-label="next" aria-disabled="true">
140  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
141  </a>
142  </span>
143 </div>
144 EOT;
145 
146  $html = $this->getDefaultRenderer()->render($p);
147  $this->assertHTMLEquals($expected_html, $html);
148  }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
disabled()
Example showing how to plug a disabled checkbox into a form.
Definition: disabled.php:5
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326
+ Here is the call graph for this function:

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