From f08e33afd80d14d99eb0595261cb100f981d4b52 Mon Sep 17 00:00:00 2001
From: Jori Stein <44996807+stein-j@users.noreply.github.com>
Date: Thu, 6 Jan 2022 21:35:56 +0100
Subject: [PATCH 1/9] Remove redondant initialization (#775)
---
src/Commands/Run.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Commands/Run.php b/src/Commands/Run.php
index 4216d1c6..aa518d7a 100644
--- a/src/Commands/Run.php
+++ b/src/Commands/Run.php
@@ -34,7 +34,6 @@ class Run extends Command
{
tenancy()->runForMultiple($this->option('tenants'), function ($tenant) {
$this->line("Tenant: {$tenant->getTenantKey()}");
- tenancy()->initialize($tenant);
$callback = function ($prefix = '') {
return function ($arguments, $argument) use ($prefix) {
From 9c79267e2444b5df4c32123f62387b71953f0a26 Mon Sep 17 00:00:00 2001
From: Erik Gaal
Date: Mon, 14 Feb 2022 14:31:01 +0100
Subject: [PATCH 2/9] Fix .env loading in development (#799)
* Upgrade vlucas/phpdotenv to ^5.0
`Dotenv::create($paths)` was the syntax for releases before v4
* Remove vlucas/phpdotenv dependency and make it work with newer versions.
---
composer.json | 1 -
tests/TestCase.php | 6 +++++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/composer.json b/composer.json
index b10f2d16..bf66e1f2 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,6 @@
"stancl/virtualcolumn": "^1.0"
},
"require-dev": {
- "vlucas/phpdotenv": "^3.3|^4.0|^5.0",
"laravel/framework": "^6.0|^7.0|^8.0",
"orchestra/testbench-browser-kit": "^4.0|^5.0|^6.0",
"league/flysystem-aws-s3-v3": "~1.0",
diff --git a/tests/TestCase.php b/tests/TestCase.php
index bbc42489..d3e42ea1 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -48,7 +48,11 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
protected function getEnvironmentSetUp($app)
{
if (file_exists(__DIR__ . '/../.env')) {
- \Dotenv\Dotenv::create(__DIR__ . '/..')->load();
+ if (method_exists(\Dotenv\Dotenv::class, 'createImmutable')) {
+ \Dotenv\Dotenv::createImmutable(__DIR__ . '/..')->load();
+ } else {
+ \Dotenv\Dotenv::create(__DIR__ . '/..')->load();
+ }
}
$app['config']->set([
From 27f916c3239fb4dbad44f1cfa74fbde4bd9d656d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Samuel=20=C5=A0tancl?=
Date: Sat, 19 Feb 2022 16:12:38 +0100
Subject: [PATCH 3/9] end tenancy in queue if the next job is not tenant aware
---
src/Bootstrappers/QueueTenancyBootstrapper.php | 10 ++++++++--
tests/Etc/tmp/queuetest.json | 1 -
tests/QueueTest.php | 5 +++++
3 files changed, 13 insertions(+), 3 deletions(-)
delete mode 100644 tests/Etc/tmp/queuetest.json
diff --git a/src/Bootstrappers/QueueTenancyBootstrapper.php b/src/Bootstrappers/QueueTenancyBootstrapper.php
index d2ce52d0..2e9aa051 100644
--- a/src/Bootstrappers/QueueTenancyBootstrapper.php
+++ b/src/Bootstrappers/QueueTenancyBootstrapper.php
@@ -75,14 +75,20 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
protected static function initializeTenancyForQueue($tenantId)
{
- // The job is not tenant-aware
if (! $tenantId) {
+ // The job is not tenant-aware
+ if (tenancy()->initialized) {
+ // Tenancy was initialized, so we revert back to the central context
+ tenancy()->end();
+ }
+
return;
}
if (tenancy()->initialized) {
+ // Tenancy is already initialized
if (tenant()->getTenantKey() === $tenantId) {
- // Tenancy is already initialized for the tenant (e.g. dispatchNow was used)
+ // It's initialized for the same tenant (e.g. dispatchNow was used, or the previous job also ran for this tenant)
return;
}
}
diff --git a/tests/Etc/tmp/queuetest.json b/tests/Etc/tmp/queuetest.json
deleted file mode 100644
index dc158c6b..00000000
--- a/tests/Etc/tmp/queuetest.json
+++ /dev/null
@@ -1 +0,0 @@
-{"userName":"Bar","shouldFail":false,"tenant_id":"The current tenant id is: a7f73c10-9879-40ae-b7b0-1ded7c1f7b1b"}
\ No newline at end of file
diff --git a/tests/QueueTest.php b/tests/QueueTest.php
index 158ad56b..afe64fea 100644
--- a/tests/QueueTest.php
+++ b/tests/QueueTest.php
@@ -55,6 +55,11 @@ class QueueTest extends TestCase
$this->valuestore = Valuestore::make(__DIR__ . '/Etc/tmp/queuetest.json')->flush();
}
+ public function tearDown(): void
+ {
+ $this->valuestore->flush();
+ }
+
protected function withFailedJobs()
{
Schema::connection('central')->create('failed_jobs', function (Blueprint $table) {
From 368d3cc99f7916af5e8290cddabd4968eeec73ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Samuel=20=C5=A0tancl?=
Date: Sat, 19 Feb 2022 16:21:27 +0100
Subject: [PATCH 4/9] add forceRefresh option to QueueTenancyBootstrapper
---
.../QueueTenancyBootstrapper.php | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/Bootstrappers/QueueTenancyBootstrapper.php b/src/Bootstrappers/QueueTenancyBootstrapper.php
index 2e9aa051..6a88f701 100644
--- a/src/Bootstrappers/QueueTenancyBootstrapper.php
+++ b/src/Bootstrappers/QueueTenancyBootstrapper.php
@@ -25,6 +25,14 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
/** @var QueueManager */
protected $queue;
+ /**
+ * Don't persist the same tenant across multiple jobs even if they have the same tenant ID.
+ *
+ * This is useful when you're changing the tenant's state (e.g. properties in the `data` column) and want the next job to initialize tenancy again
+ * with the new data. Features like the Tenant Config are only executed when tenancy is initialized, so the re-initialization is needed in some cases.
+ */
+ public static bool $forceRefresh = false;
+
/**
* The normal constructor is only executed after tenancy is bootstrapped.
* However, we're registering a hook to initialize tenancy. Therefore,
@@ -85,6 +93,17 @@ class QueueTenancyBootstrapper implements TenancyBootstrapper
return;
}
+ if (static::$forceRefresh) {
+ // Re-initialize tenancy between all jobs
+ if (tenancy()->initialized) {
+ tenancy()->end();
+ }
+
+ tenancy()->initialize(tenancy()->find($tenantId));
+
+ return;
+ }
+
if (tenancy()->initialized) {
// Tenancy is already initialized
if (tenant()->getTenantKey() === $tenantId) {
From 8e9485f9b1f51d066a791d5cf94834738383ab76 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Samuel=20=C5=A0tancl?=
Date: Sat, 19 Feb 2022 16:31:31 +0100
Subject: [PATCH 5/9] add empty queuetest.json
---
tests/Etc/tmp/queuetest.json | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 tests/Etc/tmp/queuetest.json
diff --git a/tests/Etc/tmp/queuetest.json b/tests/Etc/tmp/queuetest.json
new file mode 100644
index 00000000..e69de29b
From 5249ec7c82013a5122f076d9fac6ed2a04b8f532 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Samuel=20=C5=A0tancl?=
Date: Sat, 19 Feb 2022 16:31:45 +0100
Subject: [PATCH 6/9] ignore changes to queuetest.json
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 1d03dbec..b3223156 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@ psysh
phpunit_var_*.xml
coverage/
clover.xml
+tests/Etc/tmp/queuetest.json
From 5b9b3845261fcd5f24181f2a92911db62b26364f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Samuel=20=C5=A0tancl?=
Date: Sat, 19 Feb 2022 16:33:59 +0100
Subject: [PATCH 7/9] Remove codecov
---
.github/workflows/ci.yml | 4 ----
README.md | 1 -
2 files changed, 5 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index efb8ad02..f7b64d2d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -26,7 +26,3 @@ jobs:
run: docker-compose exec -T test composer require --no-interaction "laravel/framework:${{ matrix.laravel }}"
- name: Run tests
run: ./test
- - name: Send code coverage to codecov
- env:
- CODECOV_TOKEN: 24382d15-84e7-4a55-bea4-c4df96a24a9b
- run: bash <(curl -s https://codecov.io/bash)
diff --git a/README.md b/README.md
index 46f1b097..f4d28288 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,6 @@
-
From b4a4eab949481d2f96b0b2c1c21aa8db92a2147e Mon Sep 17 00:00:00 2001
From: masiorama
Date: Tue, 22 Feb 2022 16:26:07 +0100
Subject: [PATCH 8/9] Add drop of db views on migrate fresh command (#812)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Optionally handle drop of table views on MigrateFresh
@stancl I managed to make the modification discussed here #811
Afaik (and I can understand) this is the easiest way to handle it, but I'm open to discuss.
* Remove redundant store variable
* code style
Co-authored-by: Samuel Štancl
---
src/Commands/MigrateFresh.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/Commands/MigrateFresh.php b/src/Commands/MigrateFresh.php
index f50e2f5f..4d003db0 100644
--- a/src/Commands/MigrateFresh.php
+++ b/src/Commands/MigrateFresh.php
@@ -7,6 +7,7 @@ namespace Stancl\Tenancy\Commands;
use Illuminate\Console\Command;
use Stancl\Tenancy\Concerns\DealsWithMigrations;
use Stancl\Tenancy\Concerns\HasATenantsOption;
+use Symfony\Component\Console\Input\InputOption;
final class MigrateFresh extends Command
{
@@ -22,6 +23,8 @@ final class MigrateFresh extends Command
public function __construct()
{
parent::__construct();
+
+ $this->addOption('--drop-views', null, InputOption::VALUE_NONE, 'Drop views along with tenant tables.', null);
$this->setName('tenants:migrate-fresh');
}
@@ -37,6 +40,7 @@ final class MigrateFresh extends Command
$this->info('Dropping tables.');
$this->call('db:wipe', array_filter([
'--database' => 'tenant',
+ '--drop-views' => $this->option('drop-views'),
'--force' => true,
]));
From 79e3d53b06f33aa6e30ee4454177e1d798918704 Mon Sep 17 00:00:00 2001
From: Erik Gaal
Date: Tue, 8 Mar 2022 01:50:25 +0100
Subject: [PATCH 9/9] [3.x] Compatibility with Laravel 9 (#802)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Test on Laravel 9
* Don't extend final Kernel class
* Make FilesystemTenancyBootstrapper compatible with Flysystem v3
Co-authored-by: George
* Update tenant maintenance mode te be in line with Laravel
* Exclude PHP 7.4 <> L9 combination from testing
* add root_override-related assertions
* getPrefix -> getPathPrefix
* handle / inconsistency in s3 prefix
* Refactor Storage facade changes
Co-authored-by: George
Co-authored-by: Samuel Štancl
---
.github/workflows/ci.yml | 5 +-
composer.json | 8 +--
.../FilesystemTenancyBootstrapper.php | 31 ++++-----
.../CheckTenantForMaintenanceMode.php | 9 ++-
tests/BootstrapperTest.php | 69 +++++++++++--------
tests/Etc/ConsoleKernel.php | 2 +-
tests/MaintenanceModeTest.php | 4 +-
tests/TestCase.php | 1 +
8 files changed, 74 insertions(+), 55 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f7b64d2d..1303061a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,7 +16,10 @@ jobs:
strategy:
matrix:
php: ["7.4", "8.0"]
- laravel: ["^6.0", "^8.0"]
+ laravel: ["^6.0", "^8.0", "^9.0"]
+ exclude:
+ - laravel: "^9.0"
+ php: "7.4"
steps:
- uses: actions/checkout@v2
diff --git a/composer.json b/composer.json
index bf66e1f2..88bfea29 100644
--- a/composer.json
+++ b/composer.json
@@ -11,16 +11,16 @@
],
"require": {
"ext-json": "*",
- "illuminate/support": "^6.0|^7.0|^8.0",
+ "illuminate/support": "^6.0|^7.0|^8.0|^9.0",
"facade/ignition-contracts": "^1.0",
"ramsey/uuid": "^3.7|^4.0",
"stancl/jobpipeline": "^1.0",
"stancl/virtualcolumn": "^1.0"
},
"require-dev": {
- "laravel/framework": "^6.0|^7.0|^8.0",
- "orchestra/testbench-browser-kit": "^4.0|^5.0|^6.0",
- "league/flysystem-aws-s3-v3": "~1.0",
+ "laravel/framework": "^6.0|^7.0|^8.0|^9.0",
+ "orchestra/testbench": "^4.0|^5.0|^6.0|^7.0",
+ "league/flysystem-aws-s3-v3": "^1.0|^3.0",
"doctrine/dbal": "^2.10",
"spatie/valuestore": "^1.2.5"
},
diff --git a/src/Bootstrappers/FilesystemTenancyBootstrapper.php b/src/Bootstrappers/FilesystemTenancyBootstrapper.php
index d5ae2d50..418be93f 100644
--- a/src/Bootstrappers/FilesystemTenancyBootstrapper.php
+++ b/src/Bootstrappers/FilesystemTenancyBootstrapper.php
@@ -54,20 +54,20 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
}
// Storage facade
- foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
- /** @var FilesystemAdapter $filesystemDisk */
- $filesystemDisk = Storage::disk($disk);
- $this->originalPaths['disks'][$disk] = $filesystemDisk->getAdapter()->getPathPrefix();
+ Storage::forgetDisk($this->app['config']['tenancy.filesystem.disks']);
- if ($root = str_replace(
+ foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
+ $originalRoot = $this->app['config']["filesystems.disks.{$disk}.root"];
+ $this->originalPaths['disks'][$disk] = $originalRoot;
+
+ $finalPrefix = str_replace(
'%storage_path%',
storage_path(),
- $this->app['config']["tenancy.filesystem.root_override.{$disk}"] ?? ''
- )) {
- $filesystemDisk->getAdapter()->setPathPrefix($finalPrefix = $root);
- } else {
- $root = $this->app['config']["filesystems.disks.{$disk}.root"];
- $filesystemDisk->getAdapter()->setPathPrefix($finalPrefix = $root . "/{$suffix}");
+ $this->app['config']["tenancy.filesystem.root_override.{$disk}"] ?? '',
+ );
+
+ if (! $finalPrefix) {
+ $finalPrefix = $originalRoot . '/'. $suffix;
}
$this->app['config']["filesystems.disks.{$disk}.root"] = $finalPrefix;
@@ -84,14 +84,9 @@ class FilesystemTenancyBootstrapper implements TenancyBootstrapper
$this->app['url']->setAssetRoot($this->app['config']['app.asset_url']);
// Storage facade
+ Storage::forgetDisk($this->app['config']['tenancy.filesystem.disks']);
foreach ($this->app['config']['tenancy.filesystem.disks'] as $disk) {
- /** @var FilesystemAdapter $filesystemDisk */
- $filesystemDisk = Storage::disk($disk);
-
- $root = $this->originalPaths['disks'][$disk];
-
- $filesystemDisk->getAdapter()->setPathPrefix($root);
- $this->app['config']["filesystems.disks.{$disk}.root"] = $root;
+ $this->app['config']["filesystems.disks.{$disk}.root"] = $this->originalPaths['disks'][$disk];
}
}
}
diff --git a/src/Middleware/CheckTenantForMaintenanceMode.php b/src/Middleware/CheckTenantForMaintenanceMode.php
index 5554663f..8e29a31e 100644
--- a/src/Middleware/CheckTenantForMaintenanceMode.php
+++ b/src/Middleware/CheckTenantForMaintenanceMode.php
@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Middleware;
use Closure;
-use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
+use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
use Stancl\Tenancy\Exceptions\TenancyNotInitializedException;
use Symfony\Component\HttpFoundation\IpUtils;
@@ -29,7 +29,12 @@ class CheckTenantForMaintenanceMode extends CheckForMaintenanceMode
return $next($request);
}
- throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']);
+ throw new HttpException(
+ 503,
+ 'Service Unavailable',
+ null,
+ isset($data['retry']) ? ['Retry-After' => $data['retry']] : []
+ );
}
return $next($request);
diff --git a/tests/BootstrapperTest.php b/tests/BootstrapperTest.php
index 1b0c880d..29aa7dc9 100644
--- a/tests/BootstrapperTest.php
+++ b/tests/BootstrapperTest.php
@@ -4,23 +4,27 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Tests;
-use Illuminate\Support\Facades\Cache;
+use Illuminate\Filesystem\FilesystemAdapter;
+use ReflectionObject;
+use ReflectionProperty;
+use Illuminate\Support\Str;
use Illuminate\Support\Facades\DB;
+use Stancl\JobPipeline\JobPipeline;
+use Stancl\Tenancy\Tests\Etc\Tenant;
+use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Storage;
-use Stancl\JobPipeline\JobPipeline;
-use Stancl\Tenancy\Bootstrappers\CacheTenancyBootstrapper;
-use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
-use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
-use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
use Stancl\Tenancy\Events\TenancyEnded;
-use Stancl\Tenancy\Events\TenancyInitialized;
-use Stancl\Tenancy\Events\TenantCreated;
use Stancl\Tenancy\Jobs\CreateDatabase;
+use Stancl\Tenancy\Events\TenantCreated;
+use Stancl\Tenancy\Events\TenancyInitialized;
use Stancl\Tenancy\Listeners\BootstrapTenancy;
use Stancl\Tenancy\Listeners\RevertToCentralContext;
-use Stancl\Tenancy\Tests\Etc\Tenant;
+use Stancl\Tenancy\Bootstrappers\CacheTenancyBootstrapper;
+use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
+use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
+use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
class BootstrapperTest extends TestCase
{
@@ -165,6 +169,7 @@ class BootstrapperTest extends TestCase
$tenant2 = Tenant::create();
tenancy()->initialize($tenant1);
+
Storage::disk('public')->put('foo', 'bar');
$this->assertSame('bar', Storage::disk('public')->get('foo'));
@@ -184,30 +189,38 @@ class BootstrapperTest extends TestCase
$this->assertFalse(Storage::disk('public')->exists('foo'));
$this->assertFalse(Storage::disk('public')->exists('abc'));
+ $expected_storage_path = $old_storage_path . '/tenant' . tenant('id'); // /tenant = suffix base
+
+ // Check that disk prefixes respect the root_override logic
+ $this->assertSame($expected_storage_path . '/app/', $this->getDiskPrefix('local'));
+ $this->assertSame($expected_storage_path . '/app/public/', $this->getDiskPrefix('public'));
+ $this->assertSame('tenant' . tenant('id') . '/', ltrim($this->getDiskPrefix('s3'), '/'));
+
// Check suffixing logic
$new_storage_path = storage_path();
- $this->assertEquals($old_storage_path . '/' . config('tenancy.filesystem.suffix_base') . tenant('id'), $new_storage_path);
+ $this->assertEquals($expected_storage_path, $new_storage_path);
+ }
- foreach (config('tenancy.filesystem.disks') as $disk) {
- $suffix = config('tenancy.filesystem.suffix_base') . tenant('id');
+ protected function getDiskPrefix(string $disk): string
+ {
+ /** @var FilesystemAdapter $disk */
+ $disk = Storage::disk($disk);
+ $adapter = $disk->getAdapter();
- /** @var FilesystemAdapter $filesystemDisk */
- $filesystemDisk = Storage::disk($disk);
-
- $current_path_prefix = $filesystemDisk->getAdapter()->getPathPrefix();
-
- if ($override = config("tenancy.filesystem.root_override.{$disk}")) {
- $correct_path_prefix = str_replace('%storage_path%', storage_path(), $override);
- } else {
- if ($base = $old_storage_facade_roots[$disk]) {
- $correct_path_prefix = $base . "/$suffix/";
- } else {
- $correct_path_prefix = "$suffix/";
- }
- }
-
- $this->assertSame($correct_path_prefix, $current_path_prefix);
+ if (! Str::startsWith(app()->version(), '9.')) {
+ return $adapter->getPathPrefix();
}
+
+ $prefixer = (new ReflectionObject($adapter))->getProperty('prefixer');
+ $prefixer->setAccessible(true);
+
+ // reflection -> instance
+ $prefixer = $prefixer->getValue($adapter);
+
+ $prefix = (new ReflectionProperty($prefixer, 'prefix'));
+ $prefix->setAccessible(true);
+
+ return $prefix->getValue($prefixer);
}
// for queues see QueueTest
diff --git a/tests/Etc/ConsoleKernel.php b/tests/Etc/ConsoleKernel.php
index 1bc66365..9d37d3c6 100644
--- a/tests/Etc/ConsoleKernel.php
+++ b/tests/Etc/ConsoleKernel.php
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Tests\Etc;
-use Orchestra\Testbench\Console\Kernel;
+use Orchestra\Testbench\Foundation\Console\Kernel;
class ConsoleKernel extends Kernel
{
diff --git a/tests/MaintenanceModeTest.php b/tests/MaintenanceModeTest.php
index a8ecb064..4a8d8d0c 100644
--- a/tests/MaintenanceModeTest.php
+++ b/tests/MaintenanceModeTest.php
@@ -4,12 +4,14 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Tests;
+use Symfony\Component\HttpKernel\Exception\HttpException;
use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;
use Illuminate\Support\Facades\Route;
use Stancl\Tenancy\Database\Concerns\MaintenanceMode;
use Stancl\Tenancy\Middleware\CheckTenantForMaintenanceMode;
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
use Stancl\Tenancy\Tests\Etc\Tenant;
+use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
class MaintenanceModeTest extends TestCase
{
@@ -32,7 +34,7 @@ class MaintenanceModeTest extends TestCase
$tenant->putDownForMaintenance();
- $this->expectException(MaintenanceModeException::class);
+ $this->expectException(HttpException::class);
$this->withoutExceptionHandling()
->get('http://acme.localhost/foo');
}
diff --git a/tests/TestCase.php b/tests/TestCase.php
index d3e42ea1..cea669a1 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -87,6 +87,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
'public',
's3',
],
+ 'filesystems.disks.s3.bucket' => 'foo',
'tenancy.redis.tenancy' => env('TENANCY_TEST_REDIS_TENANCY', true),
'database.redis.client' => env('TENANCY_TEST_REDIS_CLIENT', 'phpredis'),
'tenancy.redis.prefixed_connections' => ['default'],