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

[4.x] Finish incomplete and missing tests (#947)

* complete test sqlite manager customize path

* complete test seed command works

* complete uniqe exists test

* Update SingleDatabaseTenancyTest.php

* refactor the ternary into if condition

* custom path

* simplify if condition

* random dir name

* Update SingleDatabaseTenancyTest.php

* Update CommandsTest.php

* prefix random DB name with custom_

Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
Abrar Ahmad 2022-09-24 07:08:44 +05:00 committed by GitHub
parent ab5fa7a247
commit 8e3b74f9d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 60 additions and 12 deletions

View file

@ -225,7 +225,25 @@ test('tenant database can be created on a foreign server', function () {
});
test('path used by sqlite manager can be customized', function () {
pest()->markTestIncomplete();
Event::listen(TenantCreated::class, JobPipeline::make([CreateDatabase::class])->send(function (TenantCreated $event) {
return $event->tenant;
})->toListener());
// Set custom path for SQLite file
SQLiteDatabaseManager::$path = $customPath = database_path('custom_' . Str::random(8));
if (! is_dir($customPath)) {
// Create custom directory
mkdir($customPath);
}
$name = Str::random(8). '.sqlite';
Tenant::create([
'tenancy_db_name' => $name,
'tenancy_db_connection' => 'sqlite',
]);
expect(file_exists( $customPath . '/' . $name))->toBeTrue();
});
// Datasets