Files
projectsend/tests/Unit/CapabilityRegistryTest.php
ignacionelson 23b7dc0d11 Declare the capability a managed installation's storage hangs off
Cloud instances are given a bucket rather than configuring one, which is
the counterpart of StorageConfigure above it rather than a contradiction
of it: one edition points itself at storage, the other is pointed.

Only the declaration lives here. The behaviour is in the private
cloud-modules package, the same division Branding already uses, and
without that package the capability is inert and files stay on local
disk — so a self-hosted installation that somehow holds it is unchanged.
2026-08-24 18:35:44 -03:00

48 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
use App\Modules\Platform\Capabilities\Capability;
use App\Modules\Platform\Capabilities\CapabilityRegistry;
use App\Modules\Platform\Capabilities\Edition;
test('every capability declares at least one edition', function () {
foreach (Capability::cases() as $capability) {
expect($capability->editions())->not->toBeEmpty();
}
});
test('community edition has the self-management capabilities and no cloud exclusives', function () {
$registry = new CapabilityRegistry(Edition::Community);
expect($registry->has(Capability::UsersManage))->toBeTrue()
->and($registry->has(Capability::StorageConfigure))->toBeTrue()
->and($registry->has(Capability::EmailTransportConfigure))->toBeTrue()
->and($registry->has(Capability::SystemUpdates))->toBeTrue()
->and($registry->has(Capability::SchedulerMonitoring))->toBeTrue()
->and($registry->has(Capability::CustomAssets))->toBeTrue()
->and($registry->has(Capability::Branding))->toBeFalse()
// The counterpart of StorageConfigure above: a self-hosted install
// configures its own bucket and is never handed one.
->and($registry->has(Capability::StorageManaged))->toBeFalse();
});
test('cloud edition has cloud exclusives and none of the community-only capabilities', function () {
$registry = new CapabilityRegistry(Edition::Cloud);
expect($registry->has(Capability::Branding))->toBeTrue()
->and($registry->has(Capability::StorageManaged))->toBeTrue()
->and($registry->has(Capability::UsersManage))->toBeFalse()
->and($registry->has(Capability::StorageConfigure))->toBeFalse()
->and($registry->has(Capability::EmailTransportConfigure))->toBeFalse()
->and($registry->has(Capability::SystemUpdates))->toBeFalse()
->and($registry->has(Capability::SchedulerMonitoring))->toBeFalse()
->and($registry->has(Capability::CustomAssets))->toBeFalse();
});
test('enabledKeys returns the string keys of enabled capabilities', function () {
$registry = new CapabilityRegistry(Edition::Cloud);
expect($registry->enabledKeys())->toBe(['branding.customize', 'storage.managed', 'captcha.managed_keys']);
});