ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 
 getImagePathResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
 
 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  }
+ 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 261 of file PaginationTest.php.

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

262  {
263  $p = $this->getFactory()->pagination()
264  ->withTotalEntries(3)
265  ->withPageSize(1)
266  ->withDropdownAt(1);
267 
268  $expected_html = <<<EOT
269 <div class="il-viewcontrol-pagination">
270  <span class="browse previous">
271  <a class="glyph disabled" aria-label="back" aria-disabled="true">
272  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
273  </a>
274  </span>
275 
276  <div class="dropdown">
277  <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>
278  <ul class="dropdown-menu">
279  <li><button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=0" id="id_1">1</button></li>
280  <li><button class="btn btn-link" data-action="?pagination_offset=1" id="id_2">2</button></li>
281  <li><button class="btn btn-link" data-action="?pagination_offset=2" id="id_3">3</button></li>
282  </ul>
283  </div>
284 
285  <span class="browse next">
286  <a class="glyph" href="?pagination_offset=1" aria-label="next">
287  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
288  </a>
289  </span>
290 </div>
291 EOT;
292  $html = $this->getDefaultRenderer()->render($p);
293  $this->assertHTMLEquals($expected_html, $html);
294  }
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:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ testRenderLimited()

PaginationTest::testRenderLimited ( )

Definition at line 149 of file PaginationTest.php.

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

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

◆ testRenderLimitedWithCurrentPage()

PaginationTest::testRenderLimitedWithCurrentPage ( )

Definition at line 184 of file PaginationTest.php.

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

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

◆ testRenderLimitedWithCurrentPage2()

PaginationTest::testRenderLimitedWithCurrentPage2 ( )

Definition at line 224 of file PaginationTest.php.

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

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

◆ testRenderUnlimited()

PaginationTest::testRenderUnlimited ( )

Definition at line 86 of file PaginationTest.php.

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

87  {
88  $p = $this->getFactory()->pagination()
89  ->withTotalEntries(2)
90  ->withPageSize(1);
91 
92  //two entries, first one inactive
93  //browse-left disabled
94  $expected_html = <<<EOT
95 <div class="il-viewcontrol-pagination">
96  <span class="browse previous">
97  <a class="glyph disabled" aria-label="back" aria-disabled="true">
98  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
99  </a>
100  </span>
101 
102  <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=0" id="id_1">1</button>
103  <button class="btn btn-link" data-action="?pagination_offset=1" id="id_2">2</button>
104 
105  <span class="browse next">
106  <a class="glyph" href="?pagination_offset=1" aria-label="next">
107  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
108  </a>
109  </span>
110 </div>
111 EOT;
112 
113  $html = $this->getDefaultRenderer()->render($p);
114  $this->assertHTMLEquals($expected_html, $html);
115  }
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:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

◆ testRenderWithCurrentPage()

PaginationTest::testRenderWithCurrentPage ( )

Definition at line 117 of file PaginationTest.php.

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

118  {
119  $p = $this->getFactory()->pagination()
120  ->withTotalEntries(2)
121  ->withPageSize(1)
122  ->withCurrentPage(1);
123 
124  //two entries, second one inactive
125  //browse-right disabled
126  $expected_html = <<<EOT
127 <div class="il-viewcontrol-pagination">
128  <span class="browse previous">
129  <a class="glyph" href="?pagination_offset=0" aria-label="back">
130  <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
131  </a>
132  </span>
133 
134  <button class="btn btn-link" data-action="?pagination_offset=0" id="id_1">1</button>
135  <button class="btn btn-link engaged" aria-pressed="true" data-action="?pagination_offset=1" id="id_2">2</button>
136 
137  <span class="browse next">
138  <a class="glyph disabled" aria-label="next" aria-disabled="true">
139  <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
140  </a>
141  </span>
142 </div>
143 EOT;
144 
145  $html = $this->getDefaultRenderer()->render($p);
146  $this->assertHTMLEquals($expected_html, $html);
147  }
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:372
getDefaultRenderer(JavaScriptBinding $js_binding=null, $with_stub_renderings=[])
Definition: Base.php:311
+ Here is the call graph for this function:

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