mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 06:44:04 +00:00
Remove TestCase::randomString()
This commit is contained in:
parent
6b0066c5ef
commit
a4309fdbc7
4 changed files with 8 additions and 11 deletions
|
|
@ -10,6 +10,7 @@ use Illuminate\Contracts\Http\Kernel;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||||
use Illuminate\Support\Facades\Route as RouteFacade;
|
use Illuminate\Support\Facades\Route as RouteFacade;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Stancl\Tenancy\Actions\CloneRoutesAsTenant;
|
use Stancl\Tenancy\Actions\CloneRoutesAsTenant;
|
||||||
use Stancl\Tenancy\Middleware\InitializeTenancyByPath;
|
use Stancl\Tenancy\Middleware\InitializeTenancyByPath;
|
||||||
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
|
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
|
||||||
|
|
@ -120,7 +121,7 @@ test('early identification works with path identification', function (bool $useK
|
||||||
RouteFacade::get('/{post}/comment/{comment}/edit', [$controller, 'computePost']);
|
RouteFacade::get('/{post}/comment/{comment}/edit', [$controller, 'computePost']);
|
||||||
});
|
});
|
||||||
|
|
||||||
$tenant = Tenant::create(['tenancy_db_name' => pest()->randomString()]);
|
$tenant = Tenant::create(['tenancy_db_name' => Str::random(10)]);
|
||||||
|
|
||||||
// Migrate users and comments tables on tenant connection
|
// Migrate users and comments tables on tenant connection
|
||||||
pest()->artisan('tenants:migrate', [
|
pest()->artisan('tenants:migrate', [
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Stancl\Tenancy\Actions\CloneRoutesAsTenant;
|
use Stancl\Tenancy\Actions\CloneRoutesAsTenant;
|
||||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||||
|
|
@ -44,7 +45,7 @@ test('asset can be accessed using the url returned by the tenant asset helper',
|
||||||
$tenant = Tenant::create();
|
$tenant = Tenant::create();
|
||||||
tenancy()->initialize($tenant);
|
tenancy()->initialize($tenant);
|
||||||
|
|
||||||
$filename = 'testfile' . pest()->randomString(10);
|
$filename = 'testfile' . Str::random(8);
|
||||||
Storage::disk('public')->put($filename, 'bar');
|
Storage::disk('public')->put($filename, 'bar');
|
||||||
$path = storage_path("app/public/$filename");
|
$path = storage_path("app/public/$filename");
|
||||||
|
|
||||||
|
|
@ -136,7 +137,7 @@ test('TenantAssetController headers are configurable', function () {
|
||||||
tenancy()->initialize($tenant);
|
tenancy()->initialize($tenant);
|
||||||
$tenant->createDomain('foo.localhost');
|
$tenant->createDomain('foo.localhost');
|
||||||
|
|
||||||
$filename = 'testfile' . pest()->randomString(10);
|
$filename = 'testfile' . Str::random(10);
|
||||||
Storage::disk('public')->put($filename, 'bar');
|
Storage::disk('public')->put($filename, 'bar');
|
||||||
|
|
||||||
$this->withoutExceptionHandling();
|
$this->withoutExceptionHandling();
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ test('databases can be created and deleted', function ($driver, $databaseManager
|
||||||
"tenancy.database.managers.$driver" => $databaseManager,
|
"tenancy.database.managers.$driver" => $databaseManager,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$name = 'db' . pest()->randomString();
|
$name = 'db' . Str::random(10);
|
||||||
|
|
||||||
$manager = app($databaseManager);
|
$manager = app($databaseManager);
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ test('dbs can be created when another driver is used for the central db', functi
|
||||||
return $event->tenant;
|
return $event->tenant;
|
||||||
})->toListener());
|
})->toListener());
|
||||||
|
|
||||||
$database = 'db' . pest()->randomString();
|
$database = 'db' . Str::random(10);
|
||||||
|
|
||||||
$mysqlmanager = app(MySQLDatabaseManager::class);
|
$mysqlmanager = app(MySQLDatabaseManager::class);
|
||||||
$mysqlmanager->setConnection('mysql');
|
$mysqlmanager->setConnection('mysql');
|
||||||
|
|
@ -86,7 +86,7 @@ test('dbs can be created when another driver is used for the central db', functi
|
||||||
$postgresManager = app(PostgreSQLDatabaseManager::class);
|
$postgresManager = app(PostgreSQLDatabaseManager::class);
|
||||||
$postgresManager->setConnection('pgsql');
|
$postgresManager->setConnection('pgsql');
|
||||||
|
|
||||||
$database = 'db' . pest()->randomString();
|
$database = 'db' . Str::random(10);
|
||||||
expect($postgresManager->databaseExists($database))->toBeFalse();
|
expect($postgresManager->databaseExists($database))->toBeFalse();
|
||||||
|
|
||||||
Tenant::create([
|
Tenant::create([
|
||||||
|
|
|
||||||
|
|
@ -236,11 +236,6 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
$app->singleton('Illuminate\Contracts\Console\Kernel', Etc\Console\ConsoleKernel::class);
|
$app->singleton('Illuminate\Contracts\Console\Kernel', Etc\Console\ConsoleKernel::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function randomString(int $length = 10)
|
|
||||||
{
|
|
||||||
return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', (int) (ceil($length / strlen($x))))), 1, $length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function assertArrayIsSubset($subset, $array, string $message = ''): void
|
public function assertArrayIsSubset($subset, $array, string $message = ''): void
|
||||||
{
|
{
|
||||||
parent::assertTrue(array_intersect($subset, $array) == $subset, $message);
|
parent::assertTrue(array_intersect($subset, $array) == $subset, $message);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue