Skip to content

Commit a4309fd

Browse files
committed
Remove TestCase::randomString()
1 parent 6b0066c commit a4309fd

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

tests/EarlyIdentificationTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Support\Facades\Event;
1111
use Stancl\Tenancy\Events\TenancyInitialized;
1212
use Illuminate\Support\Facades\Route as RouteFacade;
13+
use Illuminate\Support\Str;
1314
use Stancl\Tenancy\Actions\CloneRoutesAsTenant;
1415
use Stancl\Tenancy\Middleware\InitializeTenancyByPath;
1516
use Stancl\Tenancy\Middleware\InitializeTenancyByDomain;
@@ -120,7 +121,7 @@
120121
RouteFacade::get('/{post}/comment/{comment}/edit', [$controller, 'computePost']);
121122
});
122123

123-
$tenant = Tenant::create(['tenancy_db_name' => pest()->randomString()]);
124+
$tenant = Tenant::create(['tenancy_db_name' => Str::random(10)]);
124125

125126
// Migrate users and comments tables on tenant connection
126127
pest()->artisan('tenants:migrate', [

tests/TenantAssetTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Support\Facades\Event;
99
use Illuminate\Support\Facades\Route;
1010
use Illuminate\Support\Facades\Storage;
11+
use Illuminate\Support\Str;
1112
use Stancl\Tenancy\Actions\CloneRoutesAsTenant;
1213
use Stancl\Tenancy\Events\TenancyInitialized;
1314
use Stancl\Tenancy\Listeners\BootstrapTenancy;
@@ -44,7 +45,7 @@
4445
$tenant = Tenant::create();
4546
tenancy()->initialize($tenant);
4647

47-
$filename = 'testfile' . pest()->randomString(10);
48+
$filename = 'testfile' . Str::random(8);
4849
Storage::disk('public')->put($filename, 'bar');
4950
$path = storage_path("app/public/$filename");
5051

@@ -136,7 +137,7 @@
136137
tenancy()->initialize($tenant);
137138
$tenant->createDomain('foo.localhost');
138139

139-
$filename = 'testfile' . pest()->randomString(10);
140+
$filename = 'testfile' . Str::random(10);
140141
Storage::disk('public')->put($filename, 'bar');
141142

142143
$this->withoutExceptionHandling();

tests/TenantDatabaseManagerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"tenancy.database.managers.$driver" => $databaseManager,
4444
]);
4545

46-
$name = 'db' . pest()->randomString();
46+
$name = 'db' . Str::random(10);
4747

4848
$manager = app($databaseManager);
4949

@@ -70,7 +70,7 @@
7070
return $event->tenant;
7171
})->toListener());
7272

73-
$database = 'db' . pest()->randomString();
73+
$database = 'db' . Str::random(10);
7474

7575
$mysqlmanager = app(MySQLDatabaseManager::class);
7676
$mysqlmanager->setConnection('mysql');
@@ -86,7 +86,7 @@
8686
$postgresManager = app(PostgreSQLDatabaseManager::class);
8787
$postgresManager->setConnection('pgsql');
8888

89-
$database = 'db' . pest()->randomString();
89+
$database = 'db' . Str::random(10);
9090
expect($postgresManager->databaseExists($database))->toBeFalse();
9191

9292
Tenant::create([

tests/TestCase.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,6 @@ protected function resolveApplicationConsoleKernel($app)
236236
$app->singleton('Illuminate\Contracts\Console\Kernel', Etc\Console\ConsoleKernel::class);
237237
}
238238

239-
public function randomString(int $length = 10)
240-
{
241-
return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', (int) (ceil($length / strlen($x))))), 1, $length);
242-
}
243-
244239
public function assertArrayIsSubset($subset, $array, string $message = ''): void
245240
{
246241
parent::assertTrue(array_intersect($subset, $array) == $subset, $message);

0 commit comments

Comments
 (0)