Skip to content

Commit 46a8503

Browse files
committed
Add Laravel 10 compatibility
1 parent 3530b50 commit 46a8503

9 files changed

+56
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
composer.lock
44
.phpunit.result.cache
55
phpunit.xml
6+
.idea

composer.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,21 @@
1515
}
1616
],
1717
"require": {
18-
"php": "^8.0",
19-
"genealabs/laravel-pivot-events": "^9.0",
20-
"illuminate/cache": "^9.0",
21-
"illuminate/config": "^9.0",
22-
"illuminate/console": "^9.0",
23-
"illuminate/container": "^9.0",
24-
"illuminate/database": "^9.0",
25-
"illuminate/http": "^9.0",
26-
"illuminate/support": "^9.0"
18+
"php": "^8.1",
19+
"genealabs/laravel-pivot-events": "^10.0",
20+
"illuminate/cache": "^10.0",
21+
"illuminate/config": "^10.0",
22+
"illuminate/console": "^10.0",
23+
"illuminate/container": "^10.0",
24+
"illuminate/database": "^10.0",
25+
"illuminate/http": "^10.0",
26+
"illuminate/support": "^10.0"
2727
},
2828
"require-dev": {
2929
"doctrine/dbal": "^3.3",
3030
"fakerphp/faker": "^1.11",
31-
"laravel/nova": "^3.9",
32-
"orchestra/testbench-browser-kit": "^7.0",
33-
"orchestra/testbench": "^7.0",
31+
"orchestra/testbench-browser-kit": "^8.0",
32+
"orchestra/testbench": "^8.0",
3433
"php-coveralls/php-coveralls" : "^2.2",
3534
"phpmd/phpmd": "^2.11",
3635
"phpunit/phpunit": "^9.5",

tests/CreatesApplication.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,19 @@ protected function getEnvironmentSetUp($app)
138138
'pagination' => 'simple',
139139
]);
140140
}
141+
142+
public function appVersionEightAndUp(): bool
143+
{
144+
return version_compare(app()->version(), '8.0.0', '>=');
145+
}
146+
147+
public function appVersionFiveBetweenSeven(): bool
148+
{
149+
return version_compare(app()->version(), '5.6.0', '>=') && version_compare(app()->version(), '8.0.0', '<');
150+
}
151+
152+
public function appVersionOld(): bool
153+
{
154+
return version_compare(app()->version(), '5.4.0', '>=') && version_compare(app()->version(), '5.6.0', '<');
155+
}
141156
}

tests/Feature/PaginationTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ class PaginationTest extends FeatureTestCase
88
public function testPaginationProvidesDifferentLinksOnDifferentPages()
99
{
1010
// Checking the version start with 8.0.
11-
if (preg_match("/^([8|9]\.)/", app()->version())) {
11+
if ($this->appVersionEightAndUp()) {
1212
$page1ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">1</span>';
1313
$page2ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">2</span>';
1414
}
1515

16-
// Checking the version start with 5.6, 5.7, 5.8 or 6.
17-
if (preg_match("/^((5\.[6-8])|(6\.)|(7\.))/", app()->version())) {
16+
// Checking the version start with 5.6, 5.7, 5.8, 6 or 7.
17+
if ($this->appVersionFiveBetweenSeven()) {
1818
$page1ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>';
1919
$page2ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">2</span></li>';
2020
}
2121

2222
// Checking the version 5.4 and 5.5
23-
if (preg_match("/^5\.[4-5]/", app()->version())) {
23+
if ($this->appVersionOld()) {
2424
$page1ActiveLink = '<li class="active"><span>1</span></li>';
2525
$page2ActiveLink = '<li class="active"><span>2</span></li>';
2626
}
@@ -40,17 +40,17 @@ public function testPaginationProvidesDifferentLinksOnDifferentPages()
4040
public function testAdvancedPagination()
4141
{
4242
// Checking the version start with 8.0.
43-
if (preg_match("/^([8|9]\.)/", app()->version())) {
43+
if ($this->appVersionEightAndUp()) {
4444
$page1ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">1</span>';
4545
$page2ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">2</span>';
4646
}
4747

48-
if (preg_match("/^((5\.[6-8])|(6\.)|(7\.))/", app()->version())) {
48+
if ($this->appVersionFiveBetweenSeven()) {
4949
$page1ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>';
5050
$page2ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">2</span></li>';
5151
}
5252

53-
if (preg_match("/^5\.[4-5]/", app()->version())) {
53+
if ($this->appVersionOld()) {
5454
$page1ActiveLink = '<li class="active"><span>1</span></li>';
5555
$page2ActiveLink = '<li class="active"><span>2</span></li>';
5656
}
@@ -63,17 +63,17 @@ public function testAdvancedPagination()
6363
public function testCustomPagination()
6464
{
6565
// Checking the version start with 8.0.
66-
if (preg_match("/^([8|9]\.)/", app()->version())) {
66+
if ($this->appVersionEightAndUp()) {
6767
$page1ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">1</span>';
6868
$page2ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">2</span>';
6969
}
7070

71-
if (preg_match("/^((5\.[6-8])|(6\.)|(7\.))/", app()->version())) {
71+
if ($this->appVersionFiveBetweenSeven()) {
7272
$page1ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>';
7373
$page2ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">2</span></li>';
7474
}
7575

76-
if (preg_match("/^5\.[4-5]/", app()->version())) {
76+
if ($this->appVersionOld()) {
7777
$page1ActiveLink = '<li class="active"><span>1</span></li>';
7878
$page2ActiveLink = '<li class="active"><span>2</span></li>';
7979
}

tests/Fixtures/Book.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ class Book extends Model
1414

1515
protected $casts = [
1616
'price' => 'float',
17+
'published_at' => 'datetime',
1718
];
18-
protected $dates = [
19-
'published_at',
20-
];
19+
2120
protected $fillable = [
2221
"author_id",
2322
'description',

tests/Fixtures/BookWithUncachedStore.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ class BookWithUncachedStore extends Model
1414

1515
protected $casts = [
1616
'price' => 'float',
17+
'published_at' => 'datetime',
1718
];
18-
protected $dates = [
19-
'published_at',
20-
];
19+
2120
protected $fillable = [
2221
"author_id",
2322
'description',

tests/Fixtures/UncachedBook.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ class UncachedBook extends Model
1010
{
1111
protected $casts = [
1212
'price' => 'float',
13+
'published_at' => 'datetime',
1314
];
14-
protected $dates = [
15-
'published_at',
16-
];
15+
1716
protected $fillable = [
1817
'description',
1918
'published_at',
2019
'title',
2120
];
21+
2222
protected $table = 'books';
2323

2424
public function author() : BelongsTo

tests/Fixtures/UncachedBookWithStores.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ class UncachedBookWithStores extends Model
1010
{
1111
protected $casts = [
1212
'price' => 'float',
13+
'published_at' => 'datetime',
1314
];
14-
protected $dates = [
15-
'published_at',
16-
];
15+
1716
protected $fillable = [
1817
'description',
1918
'published_at',
2019
'title',
2120
];
21+
2222
protected $table = 'books';
2323

2424
public function author() : BelongsTo

tests/Integration/CachedBuilder/PaginateTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ public function testPaginationIsCached()
3636

3737
public function testPaginationReturnsCorrectLinks()
3838
{
39-
if (preg_match("/^([8|9]\.)/", app()->version())) {
39+
if ($this->appVersionEightAndUp()) {
4040
$page1ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">1</span>';
4141
$page2ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">2</span>';
4242
$page24ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">24</span>';
4343
}
4444

45-
if (preg_match("/^((5\.[6-8])|(6\.)|(7\.))/", app()->version())) {
45+
if ($this->appVersionFiveBetweenSeven()) {
4646
$page1ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>';
4747
$page2ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">2</span></li>';
4848
$page24ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">24</span></li>';
4949
}
5050

51-
if (preg_match("/^5\.[4-5]/", app()->version())) {
51+
if ($this->appVersionOld()) {
5252
$page1ActiveLink = '<li class="active"><span>1</span></li>';
5353
$page2ActiveLink = '<li class="active"><span>2</span></li>';
5454
$page24ActiveLink = '<li class="active"><span>24</span></li>';
@@ -71,19 +71,19 @@ public function testPaginationReturnsCorrectLinks()
7171

7272
public function testPaginationWithOptionsReturnsCorrectLinks()
7373
{
74-
if (preg_match("/^([8|9]\.)/", app()->version())) {
74+
if ($this->appVersionEightAndUp()) {
7575
$page1ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">1</span>';
7676
$page2ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">2</span>';
7777
$page24ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">24</span>';
7878
}
7979

80-
if (preg_match("/^((5\.[6-8])|(6\.)|(7\.))/", app()->version())) {
80+
if ($this->appVersionFiveBetweenSeven()) {
8181
$page1ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>';
8282
$page2ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">2</span></li>';
8383
$page24ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">24</span></li>';
8484
}
8585

86-
if (preg_match("/^5\.[4-5]/", app()->version())) {
86+
if ($this->appVersionOld()) {
8787
$page1ActiveLink = '<li class="active"><span>1</span></li>';
8888
$page2ActiveLink = '<li class="active"><span>2</span></li>';
8989
$page24ActiveLink = '<li class="active"><span>24</span></li>';
@@ -106,19 +106,19 @@ public function testPaginationWithOptionsReturnsCorrectLinks()
106106

107107
public function testPaginationWithCustomOptionsReturnsCorrectLinks()
108108
{
109-
if (preg_match("/^([8|9]\.)/", app()->version())) {
109+
if ($this->appVersionEightAndUp()) {
110110
$page1ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">1</span>';
111111
$page2ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">2</span>';
112112
$page24ActiveLink = '<span class="relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-500 bg-white border border-gray-300 cursor-default leading-5">24</span>';
113113
}
114114

115-
if (preg_match("/^((5\.[6-8])|(6\.)|(7\.))/", app()->version())) {
115+
if ($this->appVersionFiveBetweenSeven()) {
116116
$page1ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">1</span></li>';
117117
$page2ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">2</span></li>';
118118
$page24ActiveLink = '<li class="page-item active" aria-current="page"><span class="page-link">24</span></li>';
119119
}
120120

121-
if (preg_match("/^5\.[4-5]/", app()->version())) {
121+
if ($this->appVersionOld()) {
122122
$page1ActiveLink = '<li class="active"><span>1</span></li>';
123123
$page2ActiveLink = '<li class="active"><span>2</span></li>';
124124
$page24ActiveLink = '<li class="active"><span>24</span></li>';

0 commit comments

Comments
 (0)