1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 21:34:04 +00:00

Add link command tests back

This commit is contained in:
lukinovec 2022-08-31 07:14:51 +02:00
parent 7a055c2fd3
commit dcf29ee8c9
2 changed files with 37 additions and 2 deletions

View file

@ -50,8 +50,6 @@ class Link extends Command
} }
} catch (Exception $exception) { } catch (Exception $exception) {
$this->error($exception->getMessage()); $this->error($exception->getMessage());
return 1;
} }
} }

View file

@ -188,6 +188,43 @@ test('run command with array of tenants works', function () {
->expectsOutput('Tenant: ' . $tenantId2); ->expectsOutput('Tenant: ' . $tenantId2);
}); });
test('link command works', function() {
$tenantId1 = Tenant::create()->getTenantKey();
$tenantId2 = Tenant::create()->getTenantKey();
pest()->artisan('tenants:link');
$this->assertDirectoryExists(storage_path("tenant-$tenantId1/app/public"));
$this->assertEquals(storage_path("tenant-$tenantId1/app/public/"), readlink(public_path("public-$tenantId1")));
$this->assertDirectoryExists(storage_path("tenant-$tenantId2/app/public"));
$this->assertEquals(storage_path("tenant-$tenantId2/app/public/"), readlink(public_path("public-$tenantId2")));
pest()->artisan('tenants:link', [
'--remove' => true,
]);
$this->assertDirectoryDoesNotExist(public_path("public-$tenantId1"));
$this->assertDirectoryDoesNotExist(public_path("public-$tenantId2"));
});
test('link command works with a specified tenant', function() {
$tenantKey = Tenant::create()->getTenantKey();
pest()->artisan('tenants:link', [
'--tenants' => [$tenantKey],
]);
$this->assertDirectoryExists(storage_path("tenant-$tenantKey/app/public"));
$this->assertEquals(storage_path("tenant-$tenantKey/app/public/"), readlink(public_path("public-$tenantKey")));
pest()->artisan('tenants:link', [
'--remove' => true,
'--tenants' => [$tenantKey],
]);
$this->assertDirectoryDoesNotExist(public_path("public-$tenantKey"));
});
// todo@tests // todo@tests
function runCommandWorks(): void function runCommandWorks(): void
{ {