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

Laravel 11.x Compatibility #17

Merged
merged 1 commit into from
Apr 11, 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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Check & fix styling
name: Fix PHP code style issues

on: [push]

jobs:
php-cs-fixer:
php-code-styling:
runs-on: ubuntu-latest

steps:
Expand All @@ -12,10 +12,8 @@ jobs:
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
- name: Fix PHP code style issues
uses: aglipanci/[email protected]

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: '8.1'
coverage: none

- name: Install composer dependencies
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.3, 8.2, 8.1, 8.0]
laravel: [10.*, 9.*]
php: [8.3, 8.2, 8.1]
laravel: [11.*, 10.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
- laravel: 9.*
testbench: 7.*
carbon: ^2.63
- laravel: 11.*
testbench: 9.*
exclude:
- laravel: 10.*
php: 8.0
- laravel: 11.*
php: 8.1

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

Expand All @@ -47,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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.php_cs
.php_cs.cache
.phpunit.result.cache
.phpunit.cache
build
composer.lock
coverage
Expand Down
40 changes: 0 additions & 40 deletions .php-cs-fixer.dist.php

This file was deleted.

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 @@ -18,21 +18,21 @@
}
],
"require": {
"php": "^8.0",
"illuminate/database": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0",
"php": "^8.1",
"illuminate/database": "^10.0|^11.0",
"illuminate/support": "^10.0|^11.0",
"spatie/laravel-package-tools": "^1.14.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.7",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^7.0|^8.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"phpstan/extension-installer": "^1.1",
"laravel/pint": "^1.0",
"larastan/larastan": "^2.0.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"
"phpstan/phpstan-phpunit": "^1.3"
},
"autoload": {
"psr-4": {
Expand All @@ -46,7 +46,7 @@
}
},
"scripts": {
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"format": "vendor/bin/pint",
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest coverage"
Expand Down
4 changes: 2 additions & 2 deletions database/factories/ArticleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Maize\TenantAware\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;
use Maize\TenantAware\Tests\Support\Models\Article;
use Illuminate\Database\Eloquent\Model;
use Maize\TenantAware\Tests\Support\Models\Article;

class ArticleFactory extends Factory
{
Expand All @@ -13,7 +13,7 @@ class ArticleFactory extends Factory
public function definition()
{
return [
//
//
];
}

Expand Down
58 changes: 21 additions & 37 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,39 +1,23 @@
<?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"
>
<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"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<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">
<testsuites>
<testsuite name="Maize Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
12 changes: 6 additions & 6 deletions src/Exceptions/InvalidConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ class InvalidConfig extends Exception
{
public static function couldNotDetermineTenantModelName(): self
{
return new self("Could not determine the tenant model name. Make sure you specified a valid tenant model in the tenant aware config file");
return new self('Could not determine the tenant model name. Make sure you specified a valid tenant model in the tenant aware config file');
}

public static function couldNotDetermineTenantCurrentActionName(): self
{
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");
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');
}

public static function couldNotDetermineTenantLandlordActionName(): self
{
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");
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');
}

public static function couldNotDetermineTenantCurrentOrLandlordActionName(): self
{
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");
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');
}

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

public static function couldNotDetermineTenantOnlyCurrentActionName(): self
{
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");
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');
}
}
1 change: 0 additions & 1 deletion tests/ActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
expect(app(TenantCurrentOrLandlordAction::class)())->toBeNull();
});


it('can get only current tenant', function (Model|Builder $builder, bool $request, bool $result) {
if ($request) {
request()->merge(['tenant.only_current' => null]);
Expand Down
2 changes: 1 addition & 1 deletion tests/ModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
['tenant' => null],
]);

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

$article->setTenantKey($key);
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class Article extends Model
{
use HasFactory;
use BelongsToTenant;
use HasFactory;

protected $fillable = [
//
Expand Down
2 changes: 1 addition & 1 deletion tests/Support/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

class User extends Model
{
use HasFactory;
use BelongsToTenant;
use HasFactory;

protected $fillable = [
//
Expand Down