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.
59 lines
2.3 KiB
PHTML
59 lines
2.3 KiB
PHTML
|
2 weeks ago
|
<?php
|
||
|
|
|
||
|
|
$root = dirname(__DIR__);
|
||
|
|
$read = static function (string $path) use ($root): string {
|
||
|
|
$source = file_get_contents($root . '/' . $path);
|
||
|
|
if (!is_string($source)) {
|
||
|
|
throw new RuntimeException('Unable to read ' . $path);
|
||
|
|
}
|
||
|
|
return $source;
|
||
|
|
};
|
||
|
|
$assert = static function (bool $condition, string $message): void {
|
||
|
|
if (!$condition) {
|
||
|
|
throw new RuntimeException($message);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$order = $read('app/Services/Cloud/CloudOrderService.php');
|
||
|
|
$worker = $read('app/Services/Cloud/CloudWorkerService.php');
|
||
|
|
$renewal = $read('app/Services/Cloud/CloudRenewalService.php');
|
||
|
|
$upgrade = $read('app/Services/Cloud/CloudPlanUpgradeService.php');
|
||
|
|
|
||
|
|
$assert(str_contains($order,
|
||
|
|
'CloudTrafficPoolPeriodBinding::purchaseSnapshot(')
|
||
|
|
&& str_contains($order,
|
||
|
|
"\$safeSpec['traffic_pool_group_id'] =")
|
||
|
|
&& str_contains($order,
|
||
|
|
"\$safeSpec['traffic_quota_mode'] ="),
|
||
|
|
'Purchase does not freeze the line traffic-pool binding.');
|
||
|
|
$assert(str_contains($worker,
|
||
|
|
'CloudTrafficPoolPeriodBinding::orderSnapshot(')
|
||
|
|
&& str_contains($worker,
|
||
|
|
"\$trafficPoolBinding['traffic_pool_group_id']")
|
||
|
|
&& str_contains($worker,
|
||
|
|
'CloudTrafficPoolPeriodBinding::bindPeriod('),
|
||
|
|
'Provisioning does not consume the immutable order binding.');
|
||
|
|
$preDispatch = strpos($worker,
|
||
|
|
'self::assertCreateTrafficPoolSnapshot($job)');
|
||
|
|
$dispatchClaim = strpos($worker, "'phase' => 'dispatching'");
|
||
|
|
$assert($preDispatch !== false && $dispatchClaim !== false
|
||
|
|
&& $preDispatch < $dispatchClaim,
|
||
|
|
'Create snapshot validation no longer happens before Agent dispatch.');
|
||
|
|
$assert(str_contains($renewal,
|
||
|
|
'CloudTrafficPoolPeriodBinding::bindPeriod(')
|
||
|
|
&& str_contains($renewal,
|
||
|
|
'$lastPeriod->traffic_pool_group_id'),
|
||
|
|
'Renewal does not inherit the preceding service-period group.');
|
||
|
|
$assert(str_contains($upgrade,
|
||
|
|
'CloudTrafficPoolPeriodBinding::bindPeriod(')
|
||
|
|
&& str_contains($upgrade,
|
||
|
|
'$period->traffic_pool_group_id'),
|
||
|
|
'Upgrade no longer preserves the current service-period group.');
|
||
|
|
|
||
|
|
foreach ([$order, $worker, $renewal, $upgrade] as $source) {
|
||
|
|
$assert(!str_contains($source, 'CloudTrafficPoolAccounting::'),
|
||
|
|
'A financial or provisioning transaction directly locks pool accounting.');
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "Cloud traffic pool period integration contract passed.\n";
|