ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ViewControlPaginationTest Class Reference
+ Inheritance diagram for ViewControlPaginationTest:
+ Collaboration diagram for ViewControlPaginationTest:

Public Member Functions

 testViewControlPaginationConstruct ()
 
 testViewControlPaginationWithWrongValue ()
 
 testViewControlPaginationMutators ()
 
 testViewControlPaginationWithInput (int $offset, int $page_size, array $expected)
 
 testViewControlPaginationRendering ()
 
 testViewControlPaginationRenderingRanges ()
 
 testViewControlPaginationRenderingFindCurrent ()
 
 testViewControlPaginationRenderingEntries ()
 
 testViewControlPaginationRenderingOutsideContainer ()
 
- Public Member Functions inherited from ViewControlTestBase
 getUIFactory ()
 
 getDataFactory ()
 

Static Public Member Functions

static providePaginationInput ()
 

Protected Member Functions

 getStubRenderer ()
 
- Protected Member Functions inherited from ViewControlTestBase
 getNamesource ()
 
 buildDataFactory ()
 
 buildRefinery ()
 
 buildFieldFactory ()
 
 buildVCFactory ()
 

Detailed Description

Definition at line 49 of file ViewControlPaginationTest.php.

Member Function Documentation

◆ getStubRenderer()

ViewControlPaginationTest::getStubRenderer ( )
protected

Definition at line 213 of file ViewControlPaginationTest.php.

References ILIAS\UI\Implementation\Render\AbstractComponentRenderer\getDataFactory(), ILIAS\UI\Implementation\Render\AbstractComponentRenderer\getImagePathResolver(), getLanguage(), ILIAS\UI\Implementation\Render\AbstractComponentRenderer\getUIFactory(), and ILIAS\UI\Implementation\Render\AbstractComponentRenderer\getUploadLimitResolver().

214  {
215  return new VCPaginationRendererMock(
216  $this->getUIFactory(),
217  $this->getTemplateFactory(),
218  $this->getLanguage(),
219  $this->getJavaScriptBinding(),
220  $this->getImagePathResolver(),
221  $this->getDataFactory(),
222  $this->getHelpTextRetriever(),
223  $this->getUploadLimitResolver()
224  );
225  }
getLanguage()
+ Here is the call graph for this function:

◆ providePaginationInput()

static ViewControlPaginationTest::providePaginationInput ( )
static

Definition at line 75 of file ViewControlPaginationTest.php.

75  : array
76  {
77  return [
78  [
79  'offset' => 24,
80  'page_size' => 25,
81  'expected' => [0, 25]
82  ],
83  [
84  'offset' => 25,
85  'page_size' => 25,
86  'expected' => [25, 25]
87  ],
88  [
89  'offset' => 52,
90  'page_size' => 25,
91  'expected' => [50, 25]
92  ],
93  [
94  'offset' => 7,
95  'page_size' => 5,
96  'expected' => [5, 5]
97  ],
98  [
99  'offset' => 99,
100  'page_size' => 5,
101  'expected' => [95, 5]
102  ],
103  [
104  'offset' => 4,
105  'page_size' => 3,
106  'expected' => [3, 3]
107  ],
108  [
109  'offset' => 4,
110  'page_size' => PHP_INT_MAX,
111  'expected' => [0, PHP_INT_MAX]
112  ],
113  [
114  'offset' => 0,
115  'page_size' => 2,
116  'expected' => [0, 2]
117  ],
118  [
119  'offset' => 10,
120  'page_size' => 0,
121  'expected' => [10, 5] //default smallest limit
122  ],
123 
124  ];
125  }

◆ testViewControlPaginationConstruct()

ViewControlPaginationTest::testViewControlPaginationConstruct ( )

Definition at line 51 of file ViewControlPaginationTest.php.

51  : void
52  {
53  $vc = $this->buildVCFactory()->pagination();
54 
55  $this->assertInstanceOf(Signal::class, $vc->getInternalSignal());
56  $this->assertIsArray($vc->getLimitOptions());
57  $this->assertEquals('', $vc->getLabelLimit());
58  }

◆ testViewControlPaginationMutators()

ViewControlPaginationTest::testViewControlPaginationMutators ( )

Definition at line 67 of file ViewControlPaginationTest.php.

67  : void
68  {
69  $o = [1,2,3];
70  $l = 'limitlabel';
71  $vc = $this->buildVCFactory()->pagination();
72  $this->assertEquals($o, $vc->withLimitOptions($o)->getLimitOptions($o));
73  }

◆ testViewControlPaginationRendering()

ViewControlPaginationTest::testViewControlPaginationRendering ( )

Definition at line 160 of file ViewControlPaginationTest.php.

References $r.

160  : void
161  {
162  $r = $this->getDefaultRenderer();
163  $vc = $this->buildVCFactory()->pagination()
164  ->withLimitOptions([2, 5, 10])
165  ->withTotalCount(42)
166  ->withValue([Pagination::FNAME_OFFSET => 12, Pagination::FNAME_LIMIT => 2])
167  ->withOnChange((new SignalGenerator())->create());
168 
169  $expected = $this->brutallyTrimHTML('
170 <div class="il-viewcontrol il-viewcontrol-pagination l-bar__element" id="id_13">
171  <div class="dropdown il-viewcontrol-pagination__sectioncontrol">
172  <button class="btn btn-link" id="id_8">
173  <span class="glyph" aria-label="back" role="img"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span></span>
174  </button>
175 
176  <button class="btn btn-link" id="id_1">1</button>
177  <span class="il-viewcontrol-pagination__spacer">...</span>
178  <button class="btn btn-link" id="id_2">5</button>
179  <button class="btn btn-link" id="id_3">6</button>
180  <button class="btn btn-link engaged" aria-pressed="true" id="id_4">7</button>
181  <button class="btn btn-link" id="id_5">8</button>
182  <button class="btn btn-link" id="id_6">9</button>
183  <span class="il-viewcontrol-pagination__spacer">...</span>
184  <button class="btn btn-link" id="id_7">21</button>
185 
186  <button class="btn btn-link" id="id_9">
187  <span class="glyph" aria-label="next" role="img"><span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></span>
188  </button>
189  </div>
190 
191  <div class="dropdown il-viewcontrol-pagination__num-of-items">
192  <button class="btn btn-ctrl dropdown-toggle" type="button" data-toggle="dropdown" aria-label="label_pagination_limit" aria-haspopup="true" aria-expanded="false" aria-controls="id_13_ctrl_limit">
193  <span class="caret"></span>
194  </button>
195  <ul id="id_13_ctrl_limit" class="dropdown-menu">
196  <li class="selected"><button class="btn btn-link" id="id_10">2</button></li>
197  <li><button class="btn btn-link" id="id_11">5</button></li>
198  <li><button class="btn btn-link" id="id_12">10</button></li>
199  </ul>
200  </div>
201 
202  <div class="il-viewcontrol-value hidden" role="none">
203  <input id="id_14" type="hidden" value="12" />
204  <input id="id_15" type="hidden" value="2" />
205  </div>
206 </div>
207  ');
208 
209  $html = $this->brutallyTrimHTML($r->render($vc));
210  $this->assertEquals($expected, $html);
211  }
$r

◆ testViewControlPaginationRenderingEntries()

ViewControlPaginationTest::testViewControlPaginationRenderingEntries ( )

Definition at line 249 of file ViewControlPaginationTest.php.

References $r.

249  : void
250  {
251  $r = $this->getStubRenderer();
252  $ranges = $r->mock_buildRanges(203, 5);
253  $slices = $r->mock_sliceRangesToVisibleEntries($ranges, $current = 6, $visible_entries = 5);
254  $this->assertEquals(5, count($slices));
255  $this->assertEquals(0, $slices[0]->getStart());
256  $this->assertEquals(25, $slices[1]->getStart());
257  $this->assertEquals(30, $slices[2]->getStart());
258  $this->assertEquals(35, $slices[3]->getStart());
259  $this->assertEquals(200, $slices[4]->getStart());
260  }
$r

◆ testViewControlPaginationRenderingFindCurrent()

ViewControlPaginationTest::testViewControlPaginationRenderingFindCurrent ( )

Definition at line 238 of file ViewControlPaginationTest.php.

References $r.

238  : void
239  {
240  $r = $this->getStubRenderer();
241  $ranges = $r->mock_buildRanges(20, 5);
242  $this->assertEquals(0, $r->mock_findCurrentPage($ranges, 3));
243  $this->assertEquals(1, $r->mock_findCurrentPage($ranges, 5));
244  $this->assertEquals(1, $r->mock_findCurrentPage($ranges, 6));
245  $this->assertEquals(2, $r->mock_findCurrentPage($ranges, 10));
246  $this->assertEquals(3, $r->mock_findCurrentPage($ranges, 19));
247  }
$r

◆ testViewControlPaginationRenderingOutsideContainer()

ViewControlPaginationTest::testViewControlPaginationRenderingOutsideContainer ( )

Definition at line 262 of file ViewControlPaginationTest.php.

262  : void
263  {
264  $this->expectException(\LogicException::class);
265  $this->buildVCFactory()->pagination()->getOnChangeSignal();
266  }

◆ testViewControlPaginationRenderingRanges()

ViewControlPaginationTest::testViewControlPaginationRenderingRanges ( )

Definition at line 227 of file ViewControlPaginationTest.php.

References $r.

227  : void
228  {
229  $r = $this->getStubRenderer();
230  $ranges = $r->mock_buildRanges($total = 8, $pagelimit = 3); //0-2, 3-5, 6-7
231  $this->assertEquals(3, count($ranges));
232  $ranges = $r->mock_buildRanges(10, 5); //0-4, 5-9
233  $this->assertEquals(2, count($ranges));
234  $ranges = $r->mock_buildRanges(101, 5);
235  $this->assertEquals(21, count($ranges));
236  }
$r

◆ testViewControlPaginationWithInput()

ViewControlPaginationTest::testViewControlPaginationWithInput ( int  $offset,
int  $page_size,
array  $expected 
)

Definition at line 128 of file ViewControlPaginationTest.php.

132  : void {
133  $v = [
134  Pagination::FNAME_OFFSET => $offset,
135  Pagination::FNAME_LIMIT => $page_size
136  ];
137  $input = $this->createMock(InputData::class);
138  $input->expects($this->exactly(2))
139  ->method("getOr")
140  ->will(
141  $this->onConsecutiveCalls($v[Pagination::FNAME_OFFSET], $v[Pagination::FNAME_LIMIT])
142  );
143 
144  $vc = $this->buildVCFactory()->pagination()
145  ->withNameFrom($this->getNamesource())
146  ->withInput($input);
147 
148  $df = $this->buildDataFactory();
149  $this->assertEquals(
150  $df->ok($df->range(...$expected)),
151  $vc->getContent()
152  );
153 
154  $this->assertEquals(
155  [Pagination::FNAME_OFFSET => $offset, Pagination::FNAME_LIMIT => $page_size],
156  $vc->getValue()
157  );
158  }

◆ testViewControlPaginationWithWrongValue()

ViewControlPaginationTest::testViewControlPaginationWithWrongValue ( )

Definition at line 60 of file ViewControlPaginationTest.php.

60  : void
61  {
62  $this->expectException(\Exception::class);
63  $vc = $this->buildVCFactory()->pagination()
64  ->withValue('notokvalue:-2');
65  }

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