diff --git a/.gitignore b/.gitignore index 95abd0d..cc39bfc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ composer.lock /vendor/ .php_cs.cache +.phpunit.result.cache +.phpunit.cache \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 82db0cd..909f4e7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,13 +11,9 @@ - - - - - - - + + + @@ -31,5 +27,6 @@ + diff --git a/src/Datasource/Paginator.php b/src/Datasource/Paginator.php index bb7fb0e..5127835 100644 --- a/src/Datasource/Paginator.php +++ b/src/Datasource/Paginator.php @@ -4,7 +4,7 @@ namespace Lampager\Cake\Datasource; -use Cake\Datasource\Paginator as CakePaginator; +use Cake\Datasource\Paging\NumericPaginator as CakePaginator; use Cake\Datasource\QueryInterface; use Cake\Datasource\ResultSetInterface; use Exception; diff --git a/tests/TestCase/Datasource/PaginatorTest.php b/tests/TestCase/Datasource/PaginatorTest.php index 6823c6f..6e79aa8 100644 --- a/tests/TestCase/Datasource/PaginatorTest.php +++ b/tests/TestCase/Datasource/PaginatorTest.php @@ -7,7 +7,7 @@ use Cake\Controller\Controller; use Cake\Database\Expression\OrderClauseExpression; use Cake\Datasource\QueryInterface; -use Cake\I18n\Time; +use Cake\I18n\FrozenTime; use Cake\ORM\Entity; use Cake\ORM\Table; use Exception; @@ -32,8 +32,9 @@ class PaginatorTest extends TestCase public function testPaginateTable(callable $factory, PaginationResult $expected): void { $controller = new Controller(); - $controller->loadComponent('Paginator'); - $controller->Paginator->setPaginator(new Paginator()); + $controller->paginate = [ + 'className' => Paginator::class, + ]; /** @var Table $posts */ $posts = $controller->loadModel('Posts'); @@ -51,8 +52,9 @@ public function testPaginateTable(callable $factory, PaginationResult $expected) public function testPaginateCakeQuery(callable $factory, PaginationResult $expected): void { $controller = new Controller(); - $controller->loadComponent('Paginator'); - $controller->Paginator->setPaginator(new Paginator()); + $controller->paginate = [ + 'className' => Paginator::class, + ]; /** @var Table $posts */ $posts = $controller->loadModel('Posts'); @@ -73,8 +75,9 @@ public function testPaginateLampagerCakeQuery(callable $factory): void $this->expectExceptionMessage('Lampager\Cake\ORM\Query cannot be paginated by Lampager\Cake\Datasource\Paginator::paginate()'); $controller = new Controller(); - $controller->loadComponent('Paginator'); - $controller->Paginator->setPaginator(new Paginator()); + $controller->paginate = [ + 'className' => Paginator::class, + ]; /** @var LampagerBehavior&Table $posts */ $posts = $controller->loadModel('Posts'); @@ -92,8 +95,9 @@ public function testPaginateInvalidQuery(): void $this->expectExceptionMessage('No repository set for query.'); $controller = new Controller(); - $controller->loadComponent('Paginator'); - $controller->Paginator->setPaginator(new Paginator()); + $controller->paginate = [ + 'className' => Paginator::class, + ]; /** @var MockObject&QueryInterface $query */ $query = $this->getMockBuilder(QueryInterface::class)->getMock(); @@ -120,15 +124,15 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -137,7 +141,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 2, - 'Posts.modified' => new Time('2017-01-01 11:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -160,15 +164,15 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -177,7 +181,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 5, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -195,7 +199,7 @@ function () { ], 'cursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -203,27 +207,27 @@ function () { [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 1, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 4, - 'Posts.modified' => new Time('2017-01-01 11:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -242,7 +246,7 @@ function () { ], 'cursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -250,22 +254,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 5, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -289,22 +293,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -329,22 +333,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 5, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -364,7 +368,7 @@ function () { ], 'cursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -372,11 +376,11 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -385,7 +389,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 5, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -404,7 +408,7 @@ function () { ], 'cursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -412,7 +416,7 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -421,7 +425,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 1, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -443,15 +447,15 @@ function () { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -460,7 +464,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -483,15 +487,15 @@ function () { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -500,7 +504,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 5, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -518,7 +522,7 @@ function () { ], 'cursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -526,18 +530,18 @@ function () { [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 5, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -558,7 +562,7 @@ function () { ], 'cursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -566,14 +570,14 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 1, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -597,22 +601,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 2, - 'Posts.modified' => new Time('2017-01-01 11:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 11:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -637,22 +641,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 5, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -672,7 +676,7 @@ function () { ], 'cursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -680,27 +684,27 @@ function () { [ new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 4, - 'Posts.modified' => new Time('2017-01-01 11:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 11:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 1, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -719,7 +723,7 @@ function () { ], 'cursor' => [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -727,15 +731,15 @@ function () { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -744,7 +748,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 5, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -769,15 +773,15 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -786,7 +790,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -809,15 +813,15 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -826,7 +830,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -844,7 +848,7 @@ function () { ], 'cursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -852,27 +856,27 @@ function () { [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -891,7 +895,7 @@ function () { ], 'cursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -899,22 +903,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -938,22 +942,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -978,22 +982,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -1013,7 +1017,7 @@ function () { ], 'cursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -1021,11 +1025,11 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -1034,7 +1038,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -1053,7 +1057,7 @@ function () { ], 'cursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -1061,7 +1065,7 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -1070,7 +1074,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -1092,15 +1096,15 @@ function () { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -1109,7 +1113,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -1132,15 +1136,15 @@ function () { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -1149,7 +1153,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -1167,7 +1171,7 @@ function () { ], 'cursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -1175,18 +1179,18 @@ function () { [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -1207,7 +1211,7 @@ function () { ], 'cursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -1215,14 +1219,14 @@ function () { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -1246,22 +1250,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -1286,22 +1290,22 @@ function () { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -1321,7 +1325,7 @@ function () { ], 'cursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -1329,27 +1333,27 @@ function () { [ new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -1368,7 +1372,7 @@ function () { ], 'cursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ]; }, @@ -1376,15 +1380,15 @@ function () { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -1393,7 +1397,7 @@ function () { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), diff --git a/tests/TestCase/Model/ArrayProcessorTest.php b/tests/TestCase/Model/ArrayProcessorTest.php index af1476c..15e5ec8 100644 --- a/tests/TestCase/Model/ArrayProcessorTest.php +++ b/tests/TestCase/Model/ArrayProcessorTest.php @@ -4,7 +4,7 @@ namespace Lampager\Cake\Test\TestCase\Model; -use Cake\I18n\Time; +use Cake\I18n\FrozenTime; use Cake\ORM\Entity; use Cake\ORM\Table; use Generator; @@ -56,54 +56,54 @@ public function processProvider(): Generator ], [ 'Posts.id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], new PaginationResult( [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'Posts.id' => 1, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 4, - 'Posts.modified' => new Time('2017-01-01 11:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -121,54 +121,54 @@ public function processProvider(): Generator ], [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], new PaginationResult( [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -186,54 +186,54 @@ public function processProvider(): Generator ], [ 'id' => 3, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], new PaginationResult( [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 1, - 'Posts.modified' => new Time('2017-01-01 10:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'id' => 4, - 'Posts.modified' => new Time('2017-01-01 11:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), diff --git a/tests/TestCase/Model/Behavior/LampagerBehaviorTest.php b/tests/TestCase/Model/Behavior/LampagerBehaviorTest.php index 24606fa..bd668de 100644 --- a/tests/TestCase/Model/Behavior/LampagerBehaviorTest.php +++ b/tests/TestCase/Model/Behavior/LampagerBehaviorTest.php @@ -4,7 +4,7 @@ namespace Lampager\Cake\Test\TestCase\Model\Behavior; -use Cake\I18n\Time; +use Cake\I18n\FrozenTime; use Cake\ORM\Entity; use Cake\ORM\Table; use Cake\ORM\TableRegistry; @@ -51,15 +51,15 @@ function (Table $posts) { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -68,7 +68,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -89,15 +89,15 @@ function (Table $posts) { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -106,7 +106,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -123,34 +123,34 @@ function (Table $posts) { ->orderAsc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -168,29 +168,29 @@ function (Table $posts) { ->orderAsc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -212,22 +212,22 @@ function (Table $posts) { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -250,22 +250,22 @@ function (Table $posts) { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -284,18 +284,18 @@ function (Table $posts) { ->orderAsc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -304,7 +304,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -322,14 +322,14 @@ function (Table $posts) { ->orderAsc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -338,7 +338,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -358,15 +358,15 @@ function (Table $posts) { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -375,7 +375,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -396,15 +396,15 @@ function (Table $posts) { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -413,7 +413,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -430,25 +430,25 @@ function (Table $posts) { ->orderDesc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -468,21 +468,21 @@ function (Table $posts) { ->orderDesc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -504,22 +504,22 @@ function (Table $posts) { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -542,22 +542,22 @@ function (Table $posts) { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -576,34 +576,34 @@ function (Table $posts) { ->orderDesc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -621,22 +621,22 @@ function (Table $posts) { ->orderDesc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -645,7 +645,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -668,15 +668,15 @@ function (Table $posts) { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -685,7 +685,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -702,34 +702,34 @@ function (Table $posts) { ->orderAsc($posts->query()->newExpr('id')) ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -747,29 +747,29 @@ function (Table $posts) { ->orderAsc($posts->query()->newExpr('id')) ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -791,22 +791,22 @@ function (Table $posts) { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -829,22 +829,22 @@ function (Table $posts) { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -863,18 +863,18 @@ function (Table $posts) { ->orderAsc($posts->query()->newExpr('id')) ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -883,7 +883,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -901,14 +901,14 @@ function (Table $posts) { ->orderAsc($posts->query()->newExpr('id')) ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -917,7 +917,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -937,15 +937,15 @@ function (Table $posts) { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -954,7 +954,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -975,15 +975,15 @@ function (Table $posts) { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -992,7 +992,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -1009,25 +1009,25 @@ function (Table $posts) { ->orderDesc($posts->query()->newExpr('id')) ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -1047,21 +1047,21 @@ function (Table $posts) { ->orderDesc($posts->query()->newExpr('id')) ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => false, 'nextCursor' => null, @@ -1083,22 +1083,22 @@ function (Table $posts) { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -1121,22 +1121,22 @@ function (Table $posts) { [ new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], 'hasNext' => null, 'nextCursor' => null, @@ -1155,34 +1155,34 @@ function (Table $posts) { ->orderDesc($posts->query()->newExpr('id')) ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ 'hasPrevious' => true, 'previousCursor' => [ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], 'hasNext' => true, 'nextCursor' => [ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -1200,22 +1200,22 @@ function (Table $posts) { ->orderDesc($posts->query()->newExpr('id')) ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]); }, new PaginationResult( [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -1224,7 +1224,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), diff --git a/tests/TestCase/ORM/QueryTest.php b/tests/TestCase/ORM/QueryTest.php index 94dfa69..94279bb 100644 --- a/tests/TestCase/ORM/QueryTest.php +++ b/tests/TestCase/ORM/QueryTest.php @@ -5,7 +5,7 @@ namespace Lampager\Cake\Test\TestCase\ORM; use Cake\Database\Expression\OrderClauseExpression; -use Cake\I18n\Time; +use Cake\I18n\FrozenTime; use Cake\ORM\Entity; use Cake\ORM\Table; use Cake\ORM\TableRegistry; @@ -86,7 +86,7 @@ public function testOrderQueryExpression(): void [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -95,7 +95,7 @@ public function testOrderQueryExpression(): void 'hasNext' => true, 'nextCursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ); @@ -119,7 +119,7 @@ public function testLimitQueryExpression(): void [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -128,7 +128,7 @@ public function testLimitQueryExpression(): void 'hasNext' => true, 'nextCursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ); @@ -167,7 +167,7 @@ public function testWhere(): void [ new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -176,7 +176,7 @@ public function testWhere(): void 'hasNext' => true, 'nextCursor' => [ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ); @@ -229,12 +229,13 @@ public function testCall(): void $actual = $posts->lampager() ->orderAsc('id') + ->all() ->take(); $expected = [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ]; @@ -329,15 +330,15 @@ function (Table $posts) { [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -346,7 +347,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ], ] ), @@ -368,15 +369,15 @@ function (Table $posts) { [ new Entity([ 'id' => 4, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 2, - 'modified' => new Time('2017-01-01 11:00:00'), + 'modified' => new FrozenTime('2017-01-01 11:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -385,7 +386,7 @@ function (Table $posts) { 'hasNext' => true, 'nextCursor' => [ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ], ] ), @@ -434,7 +435,7 @@ function (Table $posts) { ->orderAsc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]) ->count(); }, @@ -453,7 +454,7 @@ function (Table $posts) { ->orderAsc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]) ->count(); }, @@ -500,7 +501,7 @@ function (Table $posts) { ->orderAsc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]) ->count(); }, @@ -519,7 +520,7 @@ function (Table $posts) { ->orderAsc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]) ->count(); }, @@ -566,7 +567,7 @@ function (Table $posts) { ->orderDesc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]) ->count(); }, @@ -585,7 +586,7 @@ function (Table $posts) { ->orderDesc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]) ->count(); }, @@ -632,7 +633,7 @@ function (Table $posts) { ->orderDesc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]) ->count(); }, @@ -651,7 +652,7 @@ function (Table $posts) { ->orderDesc('id') ->cursor([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]) ->count(); }, diff --git a/tests/TestCase/PaginationResultTest.php b/tests/TestCase/PaginationResultTest.php index e5d6b0b..2999218 100644 --- a/tests/TestCase/PaginationResultTest.php +++ b/tests/TestCase/PaginationResultTest.php @@ -5,7 +5,8 @@ namespace Lampager\Cake\Test\TestCase; use ArrayIterator; -use Cake\I18n\Time; +use Cake\Datasource\ConnectionManager; +use Cake\I18n\FrozenTime; use Cake\ORM\Entity; use Generator; use IteratorAggregate; @@ -15,6 +16,21 @@ class PaginationResultTest extends TestCase { + public function setUp(): void + { + set_error_handler( + static function ( $errno, $errstr ) { + throw new \Exception( $errstr, $errno ); + }, + E_ALL + ); + } + + public function tearDown(): void + { + restore_error_handler(); + } + /** * @param Entity[] $entities * @param Entity[]|Traversable $records @@ -217,8 +233,8 @@ public function testPublicProperties(array $entities, $records, array $meta): vo */ public function testUndefinedProperties(array $entities, $records, array $meta): void { - $this->expectError(); - $this->expectErrorMessageMatches('/^Undefined property via __get\(\): undefinedProperty/'); + $this->expectException(\Exception::class); + $this->expectExceptionMessageMatches('/^Undefined property via __get\(\): undefinedProperty/'); $paginationResult = new PaginationResult($records, $meta); $paginationResult->undefinedProperty; @@ -230,29 +246,29 @@ public function arrayProvider(): Generator [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], [ @@ -261,7 +277,7 @@ public function arrayProvider(): Generator 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 2, - 'Posts.modified' => new Time('2017-01-01 11:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 11:00:00'), ], ], '{ @@ -293,29 +309,29 @@ public function arrayProvider(): Generator [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], new ArrayIterator([ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ]), [ @@ -324,7 +340,7 @@ public function arrayProvider(): Generator 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 2, - 'Posts.modified' => new Time('2017-01-01 11:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 11:00:00'), ], ], '{ @@ -360,15 +376,15 @@ public function iteratorAggregateProvider(): Generator $iteratorAggregate->method('getIterator')->willReturn(new ArrayIterator([ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ])); @@ -376,15 +392,15 @@ public function iteratorAggregateProvider(): Generator [ new Entity([ 'id' => 1, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 3, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), new Entity([ 'id' => 5, - 'modified' => new Time('2017-01-01 10:00:00'), + 'modified' => new FrozenTime('2017-01-01 10:00:00'), ]), ], $iteratorAggregate, @@ -394,7 +410,7 @@ public function iteratorAggregateProvider(): Generator 'hasNext' => true, 'nextCursor' => [ 'Posts.id' => 2, - 'Posts.modified' => new Time('2017-01-01 11:00:00'), + 'Posts.modified' => new FrozenTime('2017-01-01 11:00:00'), ], ], '{ diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 850b28a..d799251 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -6,8 +6,10 @@ use Cake\Core\Configure; use Cake\Database\Connection; use Cake\Datasource\ConnectionManager; +use Cake\TestSuite\Fixture\SchemaLoader; use Lampager\Cake\Database\Driver\Sqlite; + require_once __DIR__ . '/../vendor/cakephp/cakephp/src/basics.php'; require_once __DIR__ . '/../vendor/autoload.php'; @@ -41,3 +43,9 @@ ConnectionManager::setConfig('test', [ 'url' => getenv('DB_DSN'), ]); + +// Create test database schema +if (env('FIXTURE_SCHEMA_METADATA')) { + $loader = new SchemaLoader(); + $loader->loadInternalFile(env('FIXTURE_SCHEMA_METADATA')); +} \ No newline at end of file diff --git a/tests/schema.php b/tests/schema.php new file mode 100644 index 0000000..1ca7ab0 --- /dev/null +++ b/tests/schema.php @@ -0,0 +1,18 @@ + 'posts', + 'columns' => [ + 'id' => ['type' => 'integer'], + 'modified' => ['type' => 'datetime'], + ], + 'constraints' => [ + 'primary' => [ + 'type' => 'primary', + 'columns' => ['id'], + ], + ], + ], +]; \ No newline at end of file