|
|
@@ -0,0 +1,50 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Opentalent\OtCore\Domain\Repository;
|
|
|
+
|
|
|
+use Nimut\TestingFramework\TestCase\UnitTestCase;
|
|
|
+
|
|
|
+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());
|
|
|
+ }
|
|
|
+}
|