1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 22:54:03 +00:00

Merge branch '3.x' into merge-3.x

This commit is contained in:
lukinovec 2023-02-20 09:07:06 +01:00
commit 790d7ff12a
12 changed files with 108 additions and 122 deletions

View file

@ -79,7 +79,7 @@ test('ing events can be used to cancel db creation', function () {
});
$tenant = Tenant::create();
dispatch_now(new CreateDatabase($tenant));
dispatch_sync(new CreateDatabase($tenant));
pest()->assertFalse($tenant->database()->manager()->databaseExists(
$tenant->database()->getName()
@ -171,12 +171,13 @@ test('database is not migrated if creation is disabled', function () {
})->toListener()
);
Tenant::create([
$tenant = Tenant::create([
'tenancy_create_database' => false,
'tenancy_db_name' => 'already_created',
]);
expect(pest()->hasFailed())->toBeFalse();
// assert test didn't fail
$this->assertTrue($tenant->exists());
});
class FooListener extends QueueableListener

View file

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
use Stancl\Tenancy\Features\ViteBundler;
use Stancl\Tenancy\Tests\Etc\Tenant;
use Stancl\Tenancy\Tests\TestCase;
use Stancl\Tenancy\Vite as StanclVite;
class ViteBundlerTest extends TestCase
{
/** @test */
public function the_vite_helper_uses_our_custom_class()
{
$vite = app(\Illuminate\Foundation\Vite::class);
$this->assertInstanceOf(\Illuminate\Foundation\Vite::class, $vite);
$this->assertNotInstanceOf(StanclVite::class, $vite);
config([
'tenancy.features' => [ViteBundler::class],
]);
$tenant = Tenant::create();
tenancy()->initialize($tenant);
app()->forgetInstance(\Illuminate\Foundation\Vite::class);
$vite = app(\Illuminate\Foundation\Vite::class);
$this->assertInstanceOf(StanclVite::class, $vite);
}
}

View file

@ -302,7 +302,7 @@ test('database credentials can be provided to PermissionControlledMySQLDatabaseM
$mysql2DB->statement("CREATE USER `{$username}`@`%` IDENTIFIED BY '{$password}';");
$mysql2DB->statement("GRANT ALL PRIVILEGES ON *.* TO `{$username}`@`%` identified by '{$password}' WITH GRANT OPTION;");
$mysql2DB->statement("FLUSH PRIVILEGES;");
DB::purge('mysql2'); // forget the mysql2 connection so that it uses the new credentials the next time
config(['database.connections.mysql2.username' => $username]);
@ -347,7 +347,7 @@ test('tenant database can be created by using the username and password from ten
$mysqlDB->statement("CREATE USER `{$username}`@`%` IDENTIFIED BY '{$password}';");
$mysqlDB->statement("GRANT ALL PRIVILEGES ON *.* TO `{$username}`@`%` identified by '{$password}' WITH GRANT OPTION;");
$mysqlDB->statement("FLUSH PRIVILEGES;");
DB::purge('mysql2'); // forget the mysql2 connection so that it uses the new credentials the next time
// Remove `mysql` credentials to make sure we will be using the credentials from the tenant config