<?php

namespace Opentalent\OtCore\Tests\Unit\Repository;

use Nimut\TestingFramework\TestCase\UnitTestCase;
use Opentalent\OtCore\Domain\Repository\ApiPagedCollection;

class ApiPagedCollectionTest extends UnitTestCase
{
    /**
     * @test
     */
    public function instantiation() {
        $collection = new ApiPagedCollection(
            5,
            2,
            1,
            ['a', 'b', 'c', 'd', 'e']
        );
        $this->assertEquals(5, $collection->getTotalItems());
        $this->assertEquals(2, $collection->getItemsPerPage());
        $this->assertEquals(1, $collection->getCurrentPage());
        $this->assertEquals(['a', 'b', 'c', 'd', 'e'], $collection->getMembers());
    }

    /**
     * @test
     */
    public function getLastPage() {
        $collection = new ApiPagedCollection(
            5,
            2,
            1,
            ['a', 'b', 'c', 'd', 'e']
        );
        $this->assertEquals(3, $collection->getLastPage());
    }

    /**
     * @test
     */
    public function getPages() {
        $collection = new ApiPagedCollection(
            5,
            2,
            1,
            ['a', 'b', 'c', 'd', 'e']
        );
        $this->assertEquals(range(1, 3), $collection->getPages());
    }
}
