Skip to content

Commit

Permalink
[3.x] Laravel 11 support (#1180)
Browse files Browse the repository at this point in the history
* Laravel 11 support

* wip

* trigger ci

* fix ci file

* try setting charset and collation on the default mysql connection

* Set default cache driver to redis in tests

* drop and recreate id column separately in autoincrement_ids_are_supported

* set default redis client to predis in tests

* revert fail-fast

* try reverting TenantModelTest change

* migrate phpunit configuration

* add parent::tearDown() call
  • Loading branch information
stancl authored Mar 12, 2024
1 parent 8db27a3 commit 72b1b48
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
php: "8.0"
- laravel: 10
php: "8.1"
- laravel: 11
php: "8.3"

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ vendor/
.idea
psysh
.phpunit.result.cache
.phpunit.cache
phpunit_var_*.xml
coverage/
clover.xml
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"require": {
"php": "^8.0",
"ext-json": "*",
"illuminate/support": "^9.0|^10.0",
"illuminate/support": "^9.0|^10.0|^11.0",
"facade/ignition-contracts": "^1.0.2",
"ramsey/uuid": "^4.7.3",
"stancl/jobpipeline": "^1.6.2",
"stancl/virtualcolumn": "^1.3.1"
},
"require-dev": {
"laravel/framework": "^9.0|^10.0",
"orchestra/testbench": "^7.0|^8.0",
"laravel/framework": "^9.0|^10.0|^11.0",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"league/flysystem-aws-s3-v3": "^3.12.2",
"doctrine/dbal": "^3.6.0",
"spatie/valuestore": "^1.3.2"
Expand Down
18 changes: 10 additions & 8 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<file>./src/routes.php</file>
<file>./src/Vite.php</file>
</exclude>
<report>
<clover outputFile="coverage/phpunit/clover.xml"/>
<html outputDirectory="coverage/phpunit/html" lowUpperBound="35" highLowerBound="70"/>
Expand All @@ -29,4 +22,13 @@
<env name="AWS_DEFAULT_REGION" value="us-west-2"/>
</php>
<logging/>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
<exclude>
<file>./src/routes.php</file>
<file>./src/Vite.php</file>
</exclude>
</source>
</phpunit>
3 changes: 1 addition & 2 deletions src/Concerns/TenantAwareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

trait TenantAwareCommand
{
/** @return int */
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$tenants = $this->getTenants();
$exitCode = 0;
Expand Down
4 changes: 1 addition & 3 deletions tests/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

namespace Stancl\Tenancy\Tests;

use Closure;
use Exception;
use Illuminate\Support\Str;
use Illuminate\Bus\Queueable;
use Spatie\Valuestore\Valuestore;
use Illuminate\Support\Facades\DB;
Expand All @@ -25,7 +23,6 @@
use Illuminate\Queue\Events\JobProcessing;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use PDO;
use Stancl\Tenancy\Events\TenancyInitialized;
use Stancl\Tenancy\Listeners\BootstrapTenancy;
use Stancl\Tenancy\Listeners\RevertToCentralContext;
Expand Down Expand Up @@ -59,6 +56,7 @@ public function setUp(): void

public function tearDown(): void
{
parent::tearDown();
$this->valuestore->flush();
}

Expand Down
4 changes: 4 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ protected function getEnvironmentSetUp($app)

$app['config']->set([
'database.default' => 'central',
'cache.default' => 'redis',
'database.redis.cache.host' => env('TENANCY_TEST_REDIS_HOST', '127.0.0.1'),
'database.redis.default.host' => env('TENANCY_TEST_REDIS_HOST', '127.0.0.1'),
'database.redis.options.prefix' => 'foo',
'database.redis.client' => 'predis',
'database.connections.central' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
Expand All @@ -80,6 +82,8 @@ protected function getEnvironmentSetUp($app)
]) : [],
],
'database.connections.sqlite.database' => ':memory:',
'database.connections.mysql.charset' => 'utf8mb4',
'database.connections.mysql.collation' => 'utf8mb4_unicode_ci',
'database.connections.mysql.host' => env('TENANCY_TEST_MYSQL_HOST', '127.0.0.1'),
'database.connections.pgsql.host' => env('TENANCY_TEST_PGSQL_HOST', '127.0.0.1'),
'tenancy.filesystem.disks' => [
Expand Down

0 comments on commit 72b1b48

Please sign in to comment.