Skip to content

Commit 373d356

Browse files
committed
added tests for paginator
1 parent a9bad63 commit 373d356

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/PaginatorTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
use Dcblogdev\MsGraph\Helpers\Paginator;
4+
5+
test('Paginator initializes correctly', function () {
6+
$paginator = new Paginator(10, 'page');
7+
8+
expect($paginator)->toBeInstanceOf(Paginator::class);
9+
});
10+
11+
test('get_start calculates correct offset', function () {
12+
$_GET['page'] = 3;
13+
$paginator = new Paginator(10, 'page');
14+
15+
expect($paginator->get_start())->toBe(20);
16+
});
17+
18+
test('setTotal updates totalRows correctly', function () {
19+
$paginator = new Paginator(10, 'page');
20+
$paginator->setTotal(50);
21+
22+
expect($paginator->page_links_array())->toHaveCount(5);
23+
});
24+
25+
test('page_links_array returns correct pagination', function () {
26+
$paginator = new Paginator(10, 'page');
27+
$paginator->setTotal(50);
28+
29+
expect($paginator->page_links_array())->toBe([1, 2, 3, 4, 5]);
30+
});
31+
32+
test('page_links generates correct HTML', function () {
33+
$paginator = new Paginator(10, 'page');
34+
$paginator->setTotal(30);
35+
36+
$html = $paginator->page_links();
37+
38+
expect($html)->toContain("<ul class='pagination'>")
39+
->and($html)->toContain("<li><a href='?page=1'>1</a></li>");
40+
});

0 commit comments

Comments
 (0)