You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt/web/tests/CloudOperationUserCopyContr...

48 lines
1.7 KiB
PHTML

<?php
require dirname(__DIR__) . '/vendor/autoload.php';
use App\Services\Cloud\CloudOperationCatalog;
use App\Services\UserCopy\UserCopyManifest;
$assert = static function (bool $condition, string $message): void {
if (!$condition) {
throw new RuntimeException($message);
}
};
$sources = CloudOperationCatalog::copySources();
$assert(count($sources) === count(CloudOperationCatalog::kinds()) + 9,
'Operation copy sources do not cover every kind, power action, setting field and separator.');
$entries = array_column(UserCopyManifest::load()['entries'], null, 'key');
foreach ($sources as $copyKey => $source) {
$entry = $entries[$copyKey] ?? null;
$assert(is_array($entry)
&& ($entry['source'] ?? null) === $source
&& ($entry['scope'] ?? null) === 'common'
&& ($entry['page'] ?? null) === 'cloud.detail'
&& ($entry['editor_surface'] ?? null) === 'admin',
'Operation copy entry is absent or has the wrong runtime/editor owner: '
. $copyKey);
}
foreach (array_keys(CloudOperationCatalog::kinds()) as $kind) {
$keys = CloudOperationCatalog::copyKeys($kind);
$assert($keys !== [] && isset($entries[$keys[0]]),
'Operation kind lacks a stable UserCopy key: ' . $kind);
}
$assert(
CloudOperationCatalog::copyKeys('action', 'shutdown')
=== ['common.operation.action.shutdown']
&& CloudOperationCatalog::copyKeys('instance_settings', null, [
'hostname', 'password',
]) === [
'common.operation.setting.hostname',
'common.operation.setting.password',
]
&& CloudOperationCatalog::copyKeys('unknown_internal_job') === [],
'Operation presentation keys do not fail closed around stable catalog codes.'
);