Skip to content

Commit 2ce63fb

Browse files
author
Riccardo Dalla Via
authored
ADD Laravel 11 compatibility
1 parent 63382d7 commit 2ce63fb

File tree

8 files changed

+41
-50
lines changed

8 files changed

+41
-50
lines changed

.github/workflows/run-tests.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ jobs:
1414
matrix:
1515
os: [ubuntu-latest, windows-latest]
1616
php: [8.3, 8.2, 8.1]
17-
laravel: [10.*]
17+
laravel: [11.*, 10.*]
1818
stability: [prefer-lowest, prefer-stable]
1919
include:
2020
- laravel: 10.*
2121
testbench: 8.*
22-
carbon: ^2.63
22+
- laravel: 11.*
23+
testbench: 9.*
24+
exclude:
25+
- laravel: 11.*
26+
php: 8.1
2327

2428
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2529

@@ -41,7 +45,7 @@ jobs:
4145
4246
- name: Install dependencies
4347
run: |
44-
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
48+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
4549
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
4650
4751
- name: Execute tests

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.idea
2-
.phpunit.result.cache
2+
.phpunit.cache
33
build
44
composer.lock
55
coverage

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2023 MAIZE SRL <[email protected]>
3+
Copyright (c) 2024 MAIZE SRL <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@
2323
],
2424
"require": {
2525
"php": "^8.1",
26-
"illuminate/console": "^10.0",
27-
"illuminate/database": "^10.0",
28-
"illuminate/notifications": "^10.0",
29-
"illuminate/support": "^10.0",
26+
"illuminate/console": "^10.0|^11.0",
27+
"illuminate/database": "^10.0|^11.0",
28+
"illuminate/notifications": "^10.0|^11.0",
29+
"illuminate/support": "^10.0|^11.0",
3030
"spatie/laravel-package-tools": "^1.14.1"
3131
},
3232
"require-dev": {
3333
"laravel/pint": "^1.0",
34-
"nunomaduro/collision": "^6.0",
34+
"nunomaduro/collision": "^7.8|^8.1",
3535
"nunomaduro/larastan": "^2.0.1",
36-
"orchestra/testbench": "^8.0",
37-
"pestphp/pest": "^1.21",
38-
"pestphp/pest-plugin-laravel": "^1.1",
39-
"phpstan/extension-installer": "^1.1",
36+
"orchestra/testbench": "^8.0|^9.0",
37+
"pestphp/pest": "^2.34",
38+
"pestphp/pest-plugin-arch": "^2.7",
39+
"pestphp/pest-plugin-laravel": "^2.3",
40+
"phpstan/extension-installer": "^1.3",
4041
"phpstan/phpstan-deprecation-rules": "^1.0",
41-
"phpstan/phpstan-phpunit": "^1.0",
42-
"phpunit/phpunit": "^9.5",
43-
"spatie/pest-plugin-test-time": "^1.1"
42+
"phpstan/phpstan-phpunit": "^1.3",
43+
"spatie/pest-plugin-test-time": "^2.1"
4444
},
4545
"autoload": {
4646
"psr-4": {

phpunit.xml.dist

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5-
backupGlobals="false"
6-
backupStaticAttributes="false"
7-
bootstrap="vendor/autoload.php"
8-
colors="true"
9-
convertErrorsToExceptions="true"
10-
convertNoticesToExceptions="true"
11-
convertWarningsToExceptions="true"
12-
processIsolation="false"
13-
stopOnFailure="false"
14-
executionOrder="random"
15-
failOnWarning="true"
16-
failOnRisky="true"
17-
failOnEmptyTestSuite="true"
18-
beStrictAboutOutputDuringTests="true"
19-
verbose="true"
20-
>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
213
<testsuites>
224
<testsuite name="Maize Test Suite">
235
<directory>tests</directory>
246
</testsuite>
257
</testsuites>
268
<coverage>
27-
<include>
28-
<directory suffix=".php">./src</directory>
29-
</include>
309
<report>
3110
<html outputDirectory="build/coverage"/>
3211
<text outputFile="build/coverage.txt"/>
@@ -36,4 +15,9 @@
3615
<logging>
3716
<junit outputFile="build/report.junit.xml"/>
3817
</logging>
18+
<source>
19+
<include>
20+
<directory suffix=".php">./src</directory>
21+
</include>
22+
</source>
3923
</phpunit>

src/HasExpiration.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,9 @@ public function getDaysLeftToExpiration(): ?int
9797
return 0;
9898
}
9999

100-
return $expiresAt
101-
->startOfDay()
102-
->diffInDays(
103-
now()->startOfDay()
104-
);
100+
return now()->startOfDay()->diffInDays(
101+
$expiresAt->startOfDay()
102+
);
105103
}
106104

107105
public function getDaysLeftToDeletion(): ?int

tests/ArchTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
it('will not use debugging functions')
4+
->expect(['dd', 'dump', 'ray'])
5+
->each->not->toBeUsed();

tests/HasExpirationTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
use function Spatie\PestPluginTestTime\testTime;
1010

11-
it('can create model with default expiration', function ($model, $expiresAt, $deletesAt) {
11+
it('can create model with default expiration', function (string $model, ?int $expiresAt, ?int $deletesAt) {
1212
testTime()->freeze();
1313

1414
$model::factory()->count(5)->create();
@@ -39,7 +39,7 @@
3939
],
4040
]);
4141

42-
it('can set expires_at', function ($model, $index, $days, $default) {
42+
it('can set expires_at', function (string $model, int $index, int $days, ?Carbon $default) {
4343
$users = $model::factory()->count(3)->create();
4444

4545
$expirations = Expiration::get();
@@ -70,7 +70,7 @@
7070
['model' => Tenant::class, 'index' => 2, 'days' => -10, 'default' => fn () => now()->startOfDay()->addDays(365)],
7171
]);
7272

73-
it('can get expires_at', function ($model, $index, $days, $default) {
73+
it('can get expires_at', function (string $model, int $index, int $days, ?Carbon $default) {
7474
testTime()->freeze();
7575

7676
$users = $model::factory()->count(3)->create();
@@ -100,7 +100,7 @@
100100
['model' => Tenant::class, 'index' => 2, 'days' => -10, 'default' => fn () => now()->startOfDay()->addDays(365)],
101101
]);
102102

103-
it('can get isExpired', function ($model, $index, $months) {
103+
it('can get isExpired', function (string $model, int $index, int $months) {
104104
testTime()->freeze();
105105

106106
$users = $model::factory()->count(3)->create();
@@ -128,7 +128,7 @@
128128
['model' => Tenant::class, 'index' => 2, 'months' => 10],
129129
]);
130130

131-
it('can get getDaysLeftToExpiration', function ($model, $index, $days, $default, $remainingIndex, $remaining) {
131+
it('can get getDaysLeftToExpiration', function (string $model, int $index, int $days, ?int $default, int $remainingIndex, ?int $remaining) {
132132
testTime()->freeze();
133133

134134
$users = $model::factory()->count(3)->create();
@@ -155,7 +155,7 @@
155155
['model' => Tenant::class, 'index' => 2, 'days' => 10, 'default' => 365, 'remaining' => 6, 'remainingIndex' => fn () => 361],
156156
]);
157157

158-
it('can get canExpire', function ($model, $index, $days, $default) {
158+
it('can get canExpire', function (string $model, int $index, int $days, bool $default) {
159159
testTime()->freeze();
160160

161161
$users = $model::factory()->count(3)->create();

0 commit comments

Comments
 (0)