Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
49 lines
1.8 KiB
PHP
49 lines
1.8 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace LIT\MCP\Tests\Support;
|
||
|
||
use LIT\MCP\Integrations\Divi\Release\CompatibilityMatrix;
|
||
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
||
use LIT\MCP\Integrations\Divi\Release\FeatureStatus;
|
||
use LIT\MCP\Integrations\Divi\Release\ReleaseGate;
|
||
use LIT\MCP\Integrations\Divi\Release\ReleaseState;
|
||
use LIT\MCP\Integrations\Divi\Release\ReleaseStatus;
|
||
|
||
/** A release status in which single Divi capabilities are locked – for guard and tool tests. */
|
||
final class DiviFeatureFixtures
|
||
{
|
||
/**
|
||
* Makes ReleaseGate answer with $states; every capability not named is released. TestCase resets the gate.
|
||
*
|
||
* @param array<string, ReleaseState> $states DiviFeature value => state
|
||
*/
|
||
public static function useStates(array $states, string $version = '5.3.0'): void
|
||
{
|
||
$features = [];
|
||
$overall = ReleaseState::Released;
|
||
foreach (DiviFeature::cases() as $feature) {
|
||
$state = $states[$feature->value] ?? ReleaseState::Released;
|
||
$features[$feature->value] = new FeatureStatus(
|
||
$feature,
|
||
$state,
|
||
$state === ReleaseState::Released ? [] : ['Abweichung bei ' . $feature->label()],
|
||
null
|
||
);
|
||
if ($state === ReleaseState::Incompatible || ($state === ReleaseState::Untested
|
||
&& $overall === ReleaseState::Released)) {
|
||
$overall = $state;
|
||
}
|
||
}
|
||
|
||
$status = new ReleaseStatus($overall, $version, null, [], null, matrix: new CompatibilityMatrix($features));
|
||
ReleaseGate::useResolver(static fn (): ReleaseStatus => $status);
|
||
}
|
||
|
||
public static function lock(DiviFeature $feature, ReleaseState $state = ReleaseState::Untested): void
|
||
{
|
||
self::useStates([$feature->value => $state]);
|
||
}
|
||
}
|