mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:44:04 +00:00
* This adds support for tenancy aware Storage::url() method * Trigger CI build * Fixed Link command for Laravel v6, added StorageLink Events, more StorageLink tests, added RemoveStorageSymlinks Job, added Storage Jobs to TenancyServiceProvider stub, renamed misleading config example. * Fix typo * Fix code style (php-cs-fixer) * Update config comments * Format code in Link command, make writing more concise * Change "symLinks" to "symlinks" * Refactor Link command * Fix test name typo * Test fetching files using the public URL * Extract Link command logic into actions * Fix code style (php-cs-fixer) * Check if closure is null in CreateStorageSymlinksAction * Stop using command terminology in CreateStorageSymlinksAction * Separate the Storage::url() test cases * Update url_override comments * Remove afterLink closures, add types, move actions, add usage explanation to the symlink trait * Fix code style (php-cs-fixer) * Update public storage URL test * Fix issue with using str() * Improve url_override comment, add todos * add todo comment * fix docblock style * Add link command tests back * Add types to $tenants in the action handle() methods * Fix typo, update variable name formatting * Add tests for the symlink actions * Change possibleTenantSymlinks not to prefix the paths twice while tenancy is initialized * Fix code style (php-cs-fixer) * Stop testing storage directory existence in symlink test * Don't specify full namespace for Tenant model annotation * Don't specify full namespace in ActionTest * Remove "change to DI" todo * Remove possibleTenantSymlinks return annotation * Remove symlink-related jobs, instantiate and use actions * Revert "Remove symlink-related jobs, instantiate and use actions" This reverts commit547440c887. * Add a comment line about the possible tenant symlinks * Correct storagePath and publicPath variables * Revert "Correct storagePath and publicPath variables" This reverts commite3aa8e2086. * add a todo Co-authored-by: Martin Vlcek <martin@dontfreakout.eu> Co-authored-by: lukinovec <lukinovec@gmail.com> Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
This commit is contained in:
parent
b78320b882
commit
7bacc50b27
18 changed files with 622 additions and 14 deletions
|
|
@ -29,6 +29,15 @@ beforeEach(function () {
|
|||
DatabaseTenancyBootstrapper::class,
|
||||
]]);
|
||||
|
||||
config([
|
||||
'tenancy.bootstrappers' => [
|
||||
DatabaseTenancyBootstrapper::class,
|
||||
],
|
||||
'tenancy.filesystem.suffix_base' => 'tenant-',
|
||||
'tenancy.filesystem.root_override.public' => '%storage_path%/app/public/',
|
||||
'tenancy.filesystem.url_override.public' => 'public-%tenant_id%'
|
||||
]);
|
||||
|
||||
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
||||
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
||||
});
|
||||
|
|
@ -196,6 +205,43 @@ test('run command with array of tenants works', function () {
|
|||
->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"));
|
||||
});
|
||||
|
||||
test('run command works when sub command asks questions and accepts arguments', function () {
|
||||
$tenant = Tenant::create();
|
||||
$id = $tenant->getTenantKey();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue