Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.4 KiB
PHP
68 lines
2.4 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\ReleaseState;
|
||
use LIT\MCP\Integrations\Divi\Release\ReleaseStatus;
|
||
|
||
/**
|
||
* Release statuses for tests, built the way production builds them (ReleaseStatus::of() with a matrix): every feature
|
||
* released except the named ones, all released, or all in one state.
|
||
*/
|
||
final class ReleaseMatrices
|
||
{
|
||
/** @param list<DiviFeature> $locked */
|
||
public static function matrix(array $locked, ReleaseState $state = ReleaseState::Untested): CompatibilityMatrix
|
||
{
|
||
$features = [];
|
||
foreach (DiviFeature::cases() as $feature) {
|
||
$features[$feature->value] = in_array($feature, $locked, true)
|
||
? new FeatureStatus(
|
||
$feature,
|
||
$state,
|
||
$state === ReleaseState::Incompatible ? ['Seiten: et_x() – Signatur geändert'] : []
|
||
)
|
||
: new FeatureStatus($feature, ReleaseState::Released, [], ReleaseStatus::SOURCE_CODE);
|
||
}
|
||
|
||
return new CompatibilityMatrix($features);
|
||
}
|
||
|
||
/** @param list<DiviFeature> $locked */
|
||
public static function status(
|
||
array $locked,
|
||
ReleaseState $state = ReleaseState::Untested,
|
||
string $version = '5.3.0'
|
||
): ReleaseStatus {
|
||
return ReleaseStatus::of($version, self::matrix($locked, $state));
|
||
}
|
||
|
||
/**
|
||
* Every feature released from $source (DiviReleases::TESTED = code, ReleaseStore = database, auto).
|
||
*
|
||
* @param array<string, mixed>|null $release The database entry of a SOURCE_DATABASE release.
|
||
*/
|
||
public static function released(
|
||
string $version = '5.2.1',
|
||
string $source = ReleaseStatus::SOURCE_CODE,
|
||
?array $release = null
|
||
): ReleaseStatus {
|
||
return ReleaseStatus::of($version, CompatibilityMatrix::allReleased($source), $release);
|
||
}
|
||
|
||
/**
|
||
* Every feature in $state with $problems (an unreleased or broken Divi as a whole).
|
||
*
|
||
* @param list<string> $problems
|
||
*/
|
||
public static function uniform(ReleaseState $state, string $version = '5.3.0', array $problems = []): ReleaseStatus
|
||
{
|
||
return ReleaseStatus::of($version, CompatibilityMatrix::uniform($state, $problems));
|
||
}
|
||
}
|