|
|
@@ -3174,4 +3174,58 @@ class PaginatorHelperTest extends TestCase
|
|
|
];
|
|
|
$this->assertHtml($expected, $out);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test using paging params set by SimplePaginator which doesn't do count query.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testMethodsWhenThereIsNoPageCount()
|
|
|
+ {
|
|
|
+ $request = new ServerRequest([
|
|
|
+ 'url' => '/',
|
|
|
+ 'params' => [
|
|
|
+ 'paging' => [
|
|
|
+ 'Article' => [
|
|
|
+ 'page' => 1,
|
|
|
+ 'current' => 9,
|
|
|
+ 'count' => null,
|
|
|
+ 'prevPage' => false,
|
|
|
+ 'nextPage' => true,
|
|
|
+ 'pageCount' => 0,
|
|
|
+ 'start' => 1,
|
|
|
+ 'end' => 9,
|
|
|
+ 'sort' => null,
|
|
|
+ 'direction' => null,
|
|
|
+ 'limit' => null,
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $view = new View($request);
|
|
|
+ $paginator = new PaginatorHelper($view);
|
|
|
+
|
|
|
+ $result = $paginator->first();
|
|
|
+ $this->assertFalse($result);
|
|
|
+
|
|
|
+ $result = $paginator->last();
|
|
|
+ $this->assertFalse($result);
|
|
|
+
|
|
|
+ // Using below methods when SimplePaginator is used makes no practical sense.
|
|
|
+ // The asserts are just to ensure they return a reasonable value.
|
|
|
+
|
|
|
+ $result = $paginator->numbers();
|
|
|
+ $this->assertFalse($result);
|
|
|
+
|
|
|
+ $result = $paginator->hasNext();
|
|
|
+ $this->assertTrue($result);
|
|
|
+
|
|
|
+ $result = $paginator->counter();
|
|
|
+ // counter() sets `pageCount` to 1 if empty.
|
|
|
+ $this->assertEquals('1 of 1', $result);
|
|
|
+
|
|
|
+ $result = $paginator->total();
|
|
|
+ $this->assertSame(0, $result);
|
|
|
+ }
|
|
|
}
|