• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 13203378522

07 Feb 2025 03:56PM UTC coverage: 8.501% (+0.7%) from 7.837%
13203378522

push

github

soyuka
Merge 4.1

111 of 490 new or added lines in 51 files covered. (22.65%)

5590 existing lines in 163 files now uncovered.

13345 of 156987 relevant lines covered (8.5%)

22.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/tests/State/Pagination/ArrayPaginatorTest.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Tests\State\Pagination;
15

16
use ApiPlatform\State\Pagination\ArrayPaginator;
17
use PHPUnit\Framework\TestCase;
18

19
/**
20
 * @author Alan Poulain <contact@alanpoulain.eu>
21
 */
22
class ArrayPaginatorTest extends TestCase
23
{
24
    #[\PHPUnit\Framework\Attributes\DataProvider('initializeProvider')]
25
    public function testInitialize(array $results, $firstResult, $maxResults, $currentItems, $totalItems, $currentPage, $lastPage, $hasNextPage): void
26
    {
27
        $paginator = new ArrayPaginator($results, $firstResult, $maxResults);
×
28

29
        $this->assertSame((float) $totalItems, $paginator->getTotalItems());
×
30
        $this->assertSame((float) $currentPage, $paginator->getCurrentPage());
×
31
        $this->assertSame((float) $lastPage, $paginator->getLastPage());
×
32
        $this->assertSame((float) $maxResults, $paginator->getItemsPerPage());
×
33
        $this->assertCount($currentItems, $paginator);
×
34
        $this->assertSame($hasNextPage, $paginator->hasNextPage());
×
35
    }
36

37
    public static function initializeProvider(): array
38
    {
39
        return [
×
40
            'First of three pages of 3 items each' => [[0, 1, 2, 3, 4, 5, 6], 0, 3, 3, 7, 1, 3, true],
×
41
            'Second of two pages of 3 items for the first page and 2 for the second' => [[0, 1, 2, 3, 4], 3, 3, 2, 5, 2, 2, false],
×
42
            'Empty results' => [[], 0, 2, 0, 0, 1, 1, false],
×
43
            '0 for max results' => [[0, 1, 2, 3], 2, 0, 0, 4, 1, 1, false],
×
44
            'First result greater than total items' => [[0, 1], 2, 1, 0, 2, 3, 2, false],
×
UNCOV
45
        ];
×
46
    }
47
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc