Skip to content

Commit

Permalink
Bump versions for Laravel 8.x (#27)
Browse files Browse the repository at this point in the history
* Bump versions for Laravel 8.x

* Fix dependency version

* Fix Date Serialization (Laravel 7.x)

* Exclude PHP 7.4 in old Laravel versions

* Remove verbose versions
  • Loading branch information
mpyw authored Oct 6, 2020
1 parent d76dea4 commit 571814b
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 77 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ filter:
build:

environment:
php: '7.3'
php: '7.4'

dependencies:
before:
Expand Down
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@ language: php

matrix:
exclude:
# [6.x] PHP 7.4 support
# https://github.com/laravel/framework/pull/29482/files
- env: LARAVEL_VERSION=5.8.* TESTBENCH_VERSION=3.8.*
php: 7.4
- env: LARAVEL_VERSION=5.7.* TESTBENCH_VERSION=3.7.*
php: 7.4
- env: LARAVEL_VERSION=5.6.* TESTBENCH_VERSION=3.6.*
php: 7.4
- env: LARAVEL_VERSION=5.5.* TESTBENCH_VERSION=3.5.*
php: 7.4
# -------
- env: LARAVEL_VERSION=^8.0 TESTBENCH_VERSION=^6.0
php: 7.2
- env: LARAVEL_VERSION=^8.0 TESTBENCH_VERSION=^6.0
php: 7.1
- env: LARAVEL_VERSION=^7.0 TESTBENCH_VERSION=^5.0
php: 7.1
- env: LARAVEL_VERSION=^6.0 TESTBENCH_VERSION=^4.0
php: 7.1

php:
- 7.4
- 7.3
- 7.2
- 7.1
Expand All @@ -16,6 +34,8 @@ cache:
- $HOME/.composer/cache

env:
- LARAVEL_VERSION=^8.0 TESTBENCH_VERSION=^6.0
- LARAVEL_VERSION=^7.0 TESTBENCH_VERSION=^5.0
- LARAVEL_VERSION=^6.0 TESTBENCH_VERSION=^4.0
- LARAVEL_VERSION=5.8.* TESTBENCH_VERSION=3.8.*
- LARAVEL_VERSION=5.7.* TESTBENCH_VERSION=3.7.*
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Rapid pagination without using OFFSET
## Requirements

- PHP: ^7.1
- Laravel: ^5.5 || ^5.6 || ^6.0 || ^7.0
- Laravel: ^5.5 || ^6.0 || ^7.0 || ^8.0
- [lampager/lampager](https://github.com/lampager/lampager): ^0.4

## Installing
Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@
}
},
"require": {
"php": "^7.1",
"php": "^7.1 || ^8.0",
"ext-json": "*",
"lampager/lampager": "^0.4",
"illuminate/contracts": "^5.5 || ^5.6 || ^6.0 || ^7.0 || ^8.0",
"illuminate/support": "^5.5 || ^5.6 || ^6.0 || ^7.0 || ^8.0",
"illuminate/database": "^5.5 || ^5.6 || ^6.0 || ^7.0 || ^8.0"
"illuminate/contracts": "^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
"illuminate/database": "^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
},
"require-dev": {
"orchestra/testbench": "^4.0",
"laravel/framework": "^6.0",
"php-coveralls/php-coveralls": "^1.0",
"orchestra/testbench": "^6.0",
"php-coveralls/php-coveralls": "^2.1",
"nilportugues/sql-query-formatter": "^1.2"
},
"extra": {
Expand Down
16 changes: 16 additions & 0 deletions tests/EloquentDate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Lampager\Laravel\Tests;

use Carbon\Carbon;
use Illuminate\Support\Facades\App;

class EloquentDate
{
public static function format(string $date): string
{
return version_compare(App::version(), '7', '>')
? Carbon::parse($date)->toJSON()
: (string)Carbon::parse($date);
}
}
12 changes: 7 additions & 5 deletions tests/PaginationResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testCollectionCall()
->paginate(['id' => 3, 'updated_at' => '2017-01-01 10:00:00']);

$this->assertResultSame(
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
$result->first()
);
}
Expand All @@ -77,20 +77,22 @@ public function testJsonEncodeWithOption()
->paginate(['id' => 3, 'updated_at' => '2017-01-01 10:00:00'])
->toJson(JSON_PRETTY_PRINT);

$expected = <<<'EOD'
$format = [EloquentDate::class, 'format'];

$expected = <<<EOD
{
"records": [
{
"id": 3,
"updated_at": "2017-01-01 10:00:00"
"updated_at": "{$format('2017-01-01 10:00:00')}"
},
{
"id": 5,
"updated_at": "2017-01-01 10:00:00"
"updated_at": "{$format('2017-01-01 10:00:00')}"
},
{
"id": 2,
"updated_at": "2017-01-01 11:00:00"
"updated_at": "{$format('2017-01-01 11:00:00')}"
}
],
"has_previous": true,
Expand Down
96 changes: 48 additions & 48 deletions tests/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public function testAscendingForwardStartInclusive()
$this->assertResultSame(
[
'records' => [
['id' => 1, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 1, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => null,
'previous_cursor' => null,
Expand All @@ -50,9 +50,9 @@ public function testAscendingForwardStartExclusive()
$this->assertResultSame(
[
'records' => [
['id' => 1, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 1, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => null,
'previous_cursor' => null,
Expand All @@ -77,9 +77,9 @@ public function testAscendingForwardInclusive()
$this->assertResultSame(
[
'records' => [
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['updated_at' => '2017-01-01 10:00:00', 'id' => 1],
Expand All @@ -103,9 +103,9 @@ public function testAscendingForwardExclusive()
$this->assertResultSame(
[
'records' => [
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 4, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 4, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['updated_at' => '2017-01-01 10:00:00', 'id' => 5],
Expand All @@ -130,9 +130,9 @@ public function testAscendingBackwardStartInclusive()
$this->assertResultSame(
[
'records' => [
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 4, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 4, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['updated_at' => '2017-01-01 10:00:00', 'id' => 3],
Expand All @@ -156,9 +156,9 @@ public function testAscendingBackwardStartExclusive()
$this->assertResultSame(
[
'records' => [
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 4, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 4, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['updated_at' => '2017-01-01 10:00:00', 'id' => 5],
Expand All @@ -183,8 +183,8 @@ public function testAscendingBackwardInclusive()
$this->assertResultSame(
[
'records' => [
['id' => 1, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 1, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => false,
'previous_cursor' => null,
Expand All @@ -208,7 +208,7 @@ public function testAscendingBackwardExclusive()
$this->assertResultSame(
[
'records' => [
['id' => 1, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 1, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => false,
'previous_cursor' => null,
Expand All @@ -233,9 +233,9 @@ public function testDescendingForwardStartInclusive()
$this->assertResultSame(
[
'records' => [
['id' => 4, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 4, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => null,
'previous_cursor' => null,
Expand All @@ -259,9 +259,9 @@ public function testDescendingForwardStartExclusive()
$this->assertResultSame(
[
'records' => [
['id' => 4, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 4, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => null,
'previous_cursor' => null,
Expand All @@ -286,8 +286,8 @@ public function testDescendingForwardInclusive()
$this->assertResultSame(
[
'records' => [
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 1, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 1, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['updated_at' => '2017-01-01 10:00:00', 'id' => 5],
Expand All @@ -311,7 +311,7 @@ public function testDescendingForwardExclusive()
$this->assertResultSame(
[
'records' => [
['id' => 1, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 1, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['updated_at' => '2017-01-01 10:00:00', 'id' => 1],
Expand All @@ -336,9 +336,9 @@ public function testDescendingBackwardStartInclusive()
$this->assertResultSame(
[
'records' => [
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 1, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 1, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['updated_at' => '2017-01-01 11:00:00', 'id' => 2],
Expand All @@ -362,9 +362,9 @@ public function testDescendingBackwardStartExclusive()
$this->assertResultSame(
[
'records' => [
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 1, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 1, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['updated_at' => '2017-01-01 10:00:00', 'id' => 5],
Expand All @@ -389,9 +389,9 @@ public function testDescendingBackwardInclusive()
$this->assertResultSame(
[
'records' => [
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['updated_at' => '2017-01-01 11:00:00', 'id' => 4],
Expand All @@ -415,9 +415,9 @@ public function testDescendingBackwardExclusive()
$this->assertResultSame(
[
'records' => [
['id' => 4, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 4, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
],
'has_previous' => false,
'previous_cursor' => null,
Expand All @@ -442,9 +442,9 @@ public function testBelongsToManyOrderByPivot()
$this->assertResultSame(
[
'records' => [
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 5, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 5, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['pivot_id' => 1],
Expand All @@ -468,9 +468,9 @@ public function testBelongsToManyOrderBySource()
$this->assertResultSame(
[
'records' => [
['id' => 2, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 3, 'updated_at' => '2017-01-01 10:00:00'],
['id' => 4, 'updated_at' => '2017-01-01 11:00:00'],
['id' => 2, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
['id' => 3, 'updated_at' => EloquentDate::format('2017-01-01 10:00:00')],
['id' => 4, 'updated_at' => EloquentDate::format('2017-01-01 11:00:00')],
],
'has_previous' => true,
'previous_cursor' => ['posts.id' => 1],
Expand Down
Loading

0 comments on commit 571814b

Please sign in to comment.