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:
parent
ab5fa7a247
commit
8e3b74f9d1
4 changed files with 60 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue