Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD Laravel 11 compatibility #5

Merged
merged 4 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.3, 8.2, 8.1]
laravel: [10.*]
laravel: [11.*, 10.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 11.*
php: 8.1

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

Expand All @@ -41,7 +45,7 @@ jobs:

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute tests
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.idea
.phpunit.result.cache
.phpunit.cache
build
composer.lock
coverage
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2023 MAIZE SRL <[email protected]>
Copyright (c) 2024 MAIZE SRL <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@
],
"require": {
"php": "^8.1",
"illuminate/console": "^10.0",
"illuminate/database": "^10.0",
"illuminate/notifications": "^10.0",
"illuminate/support": "^10.0",
"illuminate/console": "^10.0|^11.0",
"illuminate/database": "^10.0|^11.0",
"illuminate/notifications": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"spatie/laravel-package-tools": "^1.14.1"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^6.0",
"nunomaduro/collision": "^7.8|^8.1",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"phpstan/extension-installer": "^1.1",
"orchestra/testbench": "^8.0|^9.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-arch": "^2.7",
"pestphp/pest-plugin-laravel": "^2.3",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5",
"spatie/pest-plugin-test-time": "^1.1"
"phpstan/phpstan-phpunit": "^1.3",
"spatie/pest-plugin-test-time": "^2.1"
},
"autoload": {
"psr-4": {
Expand Down
28 changes: 6 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<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">
<testsuites>
<testsuite name="Maize Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
Expand All @@ -36,4 +15,9 @@
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
8 changes: 3 additions & 5 deletions src/HasExpiration.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ public function getDaysLeftToExpiration(): ?int
return 0;
}

return $expiresAt
->startOfDay()
->diffInDays(
now()->startOfDay()
);
return now()->startOfDay()->diffInDays(
$expiresAt->startOfDay()
);
}

public function getDaysLeftToDeletion(): ?int
Expand Down
5 changes: 5 additions & 0 deletions tests/ArchTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

it('will not use debugging functions')
->expect(['dd', 'dump', 'ray'])
->each->not->toBeUsed();
12 changes: 6 additions & 6 deletions tests/HasExpirationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use function Spatie\PestPluginTestTime\testTime;

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

$model::factory()->count(5)->create();
Expand Down Expand Up @@ -39,7 +39,7 @@
],
]);

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

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

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

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

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

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

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

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

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

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