ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
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 211 of file ViewControlPaginationTest.php.

212 {
213 return new VCPaginationRendererMock(
214 $this->getUIFactory(),
215 $this->getTemplateFactory(),
216 $this->getLanguage(),
217 $this->getJavaScriptBinding(),
218 $this->getImagePathResolver(),
219 $this->getDataFactory(),
220 $this->getHelpTextRetriever(),
221 $this->getUploadLimitResolver()
222 );
223 }
getLanguage()

References ILIAS\UI\Implementation\Component\Input\getDataFactory(), and 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 }

References ViewControlTestBase\buildVCFactory().

+ Here is the call graph for this function:

◆ 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 }

References ViewControlTestBase\buildVCFactory().

+ Here is the call graph for this function:

◆ testViewControlPaginationRendering()

ViewControlPaginationTest::testViewControlPaginationRendering ( )

Definition at line 158 of file ViewControlPaginationTest.php.

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

◆ testViewControlPaginationRenderingEntries()

ViewControlPaginationTest::testViewControlPaginationRenderingEntries ( )

Definition at line 247 of file ViewControlPaginationTest.php.

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

◆ testViewControlPaginationRenderingFindCurrent()

ViewControlPaginationTest::testViewControlPaginationRenderingFindCurrent ( )

Definition at line 236 of file ViewControlPaginationTest.php.

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

◆ testViewControlPaginationRenderingOutsideContainer()

ViewControlPaginationTest::testViewControlPaginationRenderingOutsideContainer ( )

Definition at line 260 of file ViewControlPaginationTest.php.

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

◆ testViewControlPaginationRenderingRanges()

ViewControlPaginationTest::testViewControlPaginationRenderingRanges ( )

Definition at line 225 of file ViewControlPaginationTest.php.

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

◆ 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 ->willReturnOnConsecutiveCalls($v[Pagination::FNAME_OFFSET], $v[Pagination::FNAME_LIMIT]);
141
142 $vc = $this->buildVCFactory()->pagination()
143 ->withNameFrom($this->getNamesource())
144 ->withInput($input);
145
146 $df = $this->buildDataFactory();
147 $this->assertEquals(
148 $df->ok($df->range(...$expected)),
149 $vc->getContent()
150 );
151
152 $this->assertEquals(
153 [Pagination::FNAME_OFFSET => $offset, Pagination::FNAME_LIMIT => $page_size],
154 $vc->getValue()
155 );
156 }

◆ 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 }

References ViewControlTestBase\buildVCFactory().

+ Here is the call graph for this function:

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