Skip to content

Commit b9051c4

Browse files
authoredApr 11, 2024··
Laravel 11.x Compatibility (#17)
1 parent 016334e commit b9051c4

14 files changed

+58
-118
lines changed
 

‎.github/workflows/php-cs-fixer.yml ‎.github/workflows/fix-php-code-style-issues.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Check & fix styling
1+
name: Fix PHP code style issues
22

33
on: [push]
44

55
jobs:
6-
php-cs-fixer:
6+
php-code-styling:
77
runs-on: ubuntu-latest
88

99
steps:
@@ -12,10 +12,8 @@ jobs:
1212
with:
1313
ref: ${{ github.head_ref }}
1414

15-
- name: Run PHP CS Fixer
16-
uses: docker://oskarstark/php-cs-fixer-ga
17-
with:
18-
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
15+
- name: Fix PHP code style issues
16+
uses: aglipanci/laravel-pint-action@2.3.1
1917

2018
- name: Commit changes
2119
uses: stefanzweifel/git-auto-commit-action@v5

‎.github/workflows/phpstan.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.0'
19+
php-version: '8.1'
2020
coverage: none
2121

2222
- name: Install composer dependencies

‎.github/workflows/run-tests.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,17 @@ jobs:
1313
fail-fast: true
1414
matrix:
1515
os: [ubuntu-latest, windows-latest]
16-
php: [8.3, 8.2, 8.1, 8.0]
17-
laravel: [10.*, 9.*]
16+
php: [8.3, 8.2, 8.1]
17+
laravel: [11.*, 10.*]
1818
stability: [prefer-lowest, prefer-stable]
1919
include:
2020
- laravel: 10.*
2121
testbench: 8.*
22-
carbon: ^2.63
23-
- laravel: 9.*
24-
testbench: 7.*
25-
carbon: ^2.63
22+
- laravel: 11.*
23+
testbench: 9.*
2624
exclude:
27-
- laravel: 10.*
28-
php: 8.0
25+
- laravel: 11.*
26+
php: 8.1
2927

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

@@ -47,7 +45,7 @@ jobs:
4745
4846
- name: Install dependencies
4947
run: |
50-
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
5149
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
5250
5351
- name: Execute tests

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.php_cs
33
.php_cs.cache
44
.phpunit.result.cache
5+
.phpunit.cache
56
build
67
composer.lock
78
coverage

‎.php-cs-fixer.dist.php

-40
This file was deleted.

‎LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2023 MAIZE SRL <info@maize.io>
3+
Copyright (c) 2024 MAIZE SRL <info@maize.io>
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

+12-12
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
}
1919
],
2020
"require": {
21-
"php": "^8.0",
22-
"illuminate/database": "^9.0|^10.0",
23-
"illuminate/support": "^9.0|^10.0",
21+
"php": "^8.1",
22+
"illuminate/database": "^10.0|^11.0",
23+
"illuminate/support": "^10.0|^11.0",
2424
"spatie/laravel-package-tools": "^1.14.1"
2525
},
2626
"require-dev": {
27-
"friendsofphp/php-cs-fixer": "^3.7",
28-
"nunomaduro/larastan": "^2.0.1",
29-
"orchestra/testbench": "^7.0|^8.0",
30-
"pestphp/pest": "^1.21",
31-
"pestphp/pest-plugin-laravel": "^1.1",
32-
"phpstan/extension-installer": "^1.1",
27+
"laravel/pint": "^1.0",
28+
"larastan/larastan": "^2.0.1",
29+
"orchestra/testbench": "^8.0|^9.0",
30+
"pestphp/pest": "^2.34",
31+
"pestphp/pest-plugin-arch": "^2.7",
32+
"pestphp/pest-plugin-laravel": "^2.3",
33+
"phpstan/extension-installer": "^1.3",
3334
"phpstan/phpstan-deprecation-rules": "^1.0",
34-
"phpstan/phpstan-phpunit": "^1.0",
35-
"phpunit/phpunit": "^9.5"
35+
"phpstan/phpstan-phpunit": "^1.3"
3636
},
3737
"autoload": {
3838
"psr-4": {
@@ -46,7 +46,7 @@
4646
}
4747
},
4848
"scripts": {
49-
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
49+
"format": "vendor/bin/pint",
5050
"analyse": "vendor/bin/phpstan analyse",
5151
"test": "vendor/bin/pest",
5252
"test-coverage": "vendor/bin/pest coverage"

‎database/factories/ArticleFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Maize\TenantAware\Database\Factories;
44

55
use Illuminate\Database\Eloquent\Factories\Factory;
6-
use Maize\TenantAware\Tests\Support\Models\Article;
76
use Illuminate\Database\Eloquent\Model;
7+
use Maize\TenantAware\Tests\Support\Models\Article;
88

99
class ArticleFactory extends Factory
1010
{
@@ -13,7 +13,7 @@ class ArticleFactory extends Factory
1313
public function definition()
1414
{
1515
return [
16-
//
16+
//
1717
];
1818
}
1919

‎phpunit.xml.dist

+21-37
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
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-
>
21-
<testsuites>
22-
<testsuite name="Maize Test Suite">
23-
<directory>tests</directory>
24-
</testsuite>
25-
</testsuites>
26-
<coverage>
27-
<include>
28-
<directory suffix=".php">./src</directory>
29-
</include>
30-
<report>
31-
<html outputDirectory="build/coverage"/>
32-
<text outputFile="build/coverage.txt"/>
33-
<clover outputFile="build/logs/clover.xml"/>
34-
</report>
35-
</coverage>
36-
<logging>
37-
<junit outputFile="build/report.junit.xml"/>
38-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/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">
3+
<testsuites>
4+
<testsuite name="Maize Test Suite">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<coverage>
9+
<report>
10+
<html outputDirectory="build/coverage"/>
11+
<text outputFile="build/coverage.txt"/>
12+
<clover outputFile="build/logs/clover.xml"/>
13+
</report>
14+
</coverage>
15+
<logging>
16+
<junit outputFile="build/report.junit.xml"/>
17+
</logging>
18+
<source>
19+
<include>
20+
<directory suffix=".php">./src</directory>
21+
</include>
22+
</source>
3923
</phpunit>

‎src/Exceptions/InvalidConfig.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@ class InvalidConfig extends Exception
88
{
99
public static function couldNotDetermineTenantModelName(): self
1010
{
11-
return new self("Could not determine the tenant model name. Make sure you specified a valid tenant model in the tenant aware config file");
11+
return new self('Could not determine the tenant model name. Make sure you specified a valid tenant model in the tenant aware config file');
1212
}
1313

1414
public static function couldNotDetermineTenantCurrentActionName(): self
1515
{
16-
return new self("Could not determine the tenant current action name. Make sure you specified a valid tenant current action in the tenant aware config file");
16+
return new self('Could not determine the tenant current action name. Make sure you specified a valid tenant current action in the tenant aware config file');
1717
}
1818

1919
public static function couldNotDetermineTenantLandlordActionName(): self
2020
{
21-
return new self("Could not determine the tenant landlord action name. Make sure you specified a valid tenant landlord action in the tenant aware config file");
21+
return new self('Could not determine the tenant landlord action name. Make sure you specified a valid tenant landlord action in the tenant aware config file');
2222
}
2323

2424
public static function couldNotDetermineTenantCurrentOrLandlordActionName(): self
2525
{
26-
return new self("Could not determine the tenant current or landlord action name. Make sure you specified a valid tenant current or landlord action in the tenant aware config file");
26+
return new self('Could not determine the tenant current or landlord action name. Make sure you specified a valid tenant current or landlord action in the tenant aware config file');
2727
}
2828

2929
public static function couldNotDetermineScopeApplyName(): self
3030
{
31-
return new self("Could not determine the scope apply name. Make sure you specified a valid scope apply in the tenant aware config file");
31+
return new self('Could not determine the scope apply name. Make sure you specified a valid scope apply in the tenant aware config file');
3232
}
3333

3434
public static function couldNotDetermineTenantOnlyCurrentActionName(): self
3535
{
36-
return new self("Could not determine the tenant only current action name. Make sure you specified a valid tenant only current action in the tenant aware config file");
36+
return new self('Could not determine the tenant only current action name. Make sure you specified a valid tenant only current action in the tenant aware config file');
3737
}
3838
}

‎tests/ActionTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
expect(app(TenantCurrentOrLandlordAction::class)())->toBeNull();
2020
});
2121

22-
2322
it('can get only current tenant', function (Model|Builder $builder, bool $request, bool $result) {
2423
if ($request) {
2524
request()->merge(['tenant.only_current' => null]);

‎tests/ModelTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
['tenant' => null],
4949
]);
5050

51-
it('can set tenant key on model', function (mixed $key, mixed $result) {
51+
it('can set tenant key on model', function (Tenant|int|null $key, Tenant|int|null $result) {
5252
$article = Article::factory()->create();
5353

5454
$article->setTenantKey($key);

‎tests/Support/Models/Article.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class Article extends Model
1010
{
11-
use HasFactory;
1211
use BelongsToTenant;
12+
use HasFactory;
1313

1414
protected $fillable = [
1515
//

‎tests/Support/Models/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
class User extends Model
1010
{
11-
use HasFactory;
1211
use BelongsToTenant;
12+
use HasFactory;
1313

1414
protected $fillable = [
1515
//

0 commit comments

Comments
 (0)
Please sign in to comment.