Skip to content

Commit 962cab0

Browse files
committed
Improve test coverage.
1 parent a21baf7 commit 962cab0

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

tests/InlineKeyboardPaginationTest.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ public function testInvalidPagination()
9898
$ikp->getPagination($ikp->getNumberOfPages() + 1);
9999
}
100100

101+
public function testSetMaxButtons()
102+
{
103+
$ikp = new InlineKeyboardPagination($this->items, $this->command, $this->selected_page, $this->items_per_page);
104+
$ikp->setMaxButtons(6);
105+
self::assertTrue(true);
106+
}
107+
101108
/**
102109
* @expectedException \TelegramBot\InlineKeyboardPagination\Exceptions\InlineKeyboardPaginationException
103110
* @expectedExceptionMessage Invalid max buttons, must be between 5 and 8.
@@ -120,6 +127,22 @@ public function testInvalidSelectedPage()
120127
$ikp->getPagination();
121128
}
122129

130+
public function testGetItemsPerPage()
131+
{
132+
$ikp = new InlineKeyboardPagination($this->items, $this->command, $this->selected_page, 4);
133+
self::assertEquals(4, $ikp->getItemsPerPage());
134+
}
135+
136+
/**
137+
* @expectedException \TelegramBot\InlineKeyboardPagination\Exceptions\InlineKeyboardPaginationException
138+
* @expectedExceptionMessage Invalid number of items per page, must be at least 1
139+
*/
140+
public function testInvalidItemsPerPage()
141+
{
142+
$ikp = new InlineKeyboardPagination($this->items, $this->command, $this->selected_page, 0);
143+
$ikp->getPagination();
144+
}
145+
123146
public function testButtonLabels()
124147
{
125148
$cbdata = '%s?currentPage=%d&nextPage=%d';
@@ -185,13 +208,16 @@ public function testButtonLabels()
185208

186209
// custom labels, skipping some buttons
187210
// first, previous, current, next, last
188-
$ikp10->setLabels([
211+
$labels = [
189212
'first' => '',
190213
'previous' => 'previous %d',
191214
'current' => null,
192215
'next' => '%d next',
193216
'last' => 'last',
194-
]);
217+
];
218+
$ikp10->setLabels($labels);
219+
self::assertEquals($labels, $ikp10->getLabels());
220+
195221
$keyboard = $ikp10->getPagination(5)['keyboard'];
196222
self::assertAllButtonPropertiesEqual([
197223
['previous 4', '6 next', 'last'],

0 commit comments

Comments
 (0)