<?php

use PHPUnit\Framework\TestCase;

final class PaginationHelperTest extends TestCase
{
    protected function setUp(): void
    {
        require_once APPPATH . 'Helpers/pagination_helper.php';
    }

    public function testPageNeverNegative(): void
    {
        $p = pagination_params(0, 25);
        $this->assertSame(1, $p['page']);
        $this->assertSame(0, $p['offset']);

        $p2 = pagination_params(-5, 25);
        $this->assertSame(1, $p2['page']);
        $this->assertSame(0, $p2['offset']);
    }

    public function testOffsetCalculation(): void
    {
        $p = pagination_params(3, 25);
        $this->assertSame(3, $p['page']);
        $this->assertSame(50, $p['offset']);
        $this->assertSame(25, $p['perPage']);
    }
}
