82 lines
3.1 KiB
PHP
82 lines
3.1 KiB
PHP
<?php
|
|
|
|
use Toolbox\Catalog;
|
|
|
|
Harness::suite('group11-compat');
|
|
|
|
$GLOBALS['g11_repo'] = dirname(__DIR__);
|
|
|
|
/**
|
|
* Contratos:
|
|
* - levels.json debe cubrir exactamente los componentes del catalogo.
|
|
* - si tests/compat/report.json existe: todo 'tested' declarado debe estar
|
|
* respaldado por un 'ok' del reporte, y el nivel 'none' de evidencia debe
|
|
* coincidir con la declaracion 'core: none' del manifiesto (bidireccional).
|
|
* Sin reporte (entorno offline sin haber corrido el barrido) solo se exige el
|
|
* primer contrato.
|
|
*/
|
|
Harness::it('levels.json cubre exactamente los componentes del catalogo', function () {
|
|
$repo = $GLOBALS['g11_repo'];
|
|
$levels = json_decode((string) file_get_contents($repo . '/tests/compat/levels.json'), true);
|
|
ok(is_array($levels), 'levels.json debe ser un objeto por paquete');
|
|
|
|
$catalog = Catalog::fromRoot($repo);
|
|
$declared = [];
|
|
foreach ($catalog->packages() as $manifest) {
|
|
foreach (array_keys($manifest->components()) as $component) {
|
|
$declared[] = $manifest->name . ':' . $component;
|
|
}
|
|
}
|
|
|
|
$planned = [];
|
|
foreach ($levels as $package => $components) {
|
|
foreach (array_keys($components) as $component) {
|
|
$planned[] = $package . ':' . $component;
|
|
}
|
|
}
|
|
|
|
sort($declared);
|
|
sort($planned);
|
|
eq($declared, $planned, 'cada componente del catalogo tiene su nivel de evidencia planeado');
|
|
});
|
|
|
|
Harness::it('los stamps tested estan respaldados por el reporte del barrido', function () {
|
|
$repo = $GLOBALS['g11_repo'];
|
|
$reportPath = $repo . '/tests/compat/report.json';
|
|
|
|
if (!is_file($reportPath)) {
|
|
return; // offline sin barrido previo: no se inventa evidencia ni se exige.
|
|
}
|
|
|
|
$report = json_decode((string) file_get_contents($reportPath), true);
|
|
ok(is_array($report) && isset($report['components']), 'report.json valido');
|
|
|
|
$levels = json_decode((string) file_get_contents($repo . '/tests/compat/levels.json'), true);
|
|
$catalog = Catalog::fromRoot($repo);
|
|
|
|
foreach ($catalog->packages() as $manifest) {
|
|
foreach (array_keys($manifest->components()) as $component) {
|
|
$id = $manifest->name . ':' . $component;
|
|
$level = $levels[$manifest->name][$component] ?? null;
|
|
$level = is_array($level) ? $level['level'] : $level;
|
|
$status = $report['components'][$id]['status'] ?? 'missing';
|
|
$tested = $manifest->testedCore($component);
|
|
$independ = $manifest->coreIndependent($component);
|
|
|
|
if ($level === 'none') {
|
|
ok($independ, "$id esta sin evidencia de barrido y debe declarar core none");
|
|
}
|
|
|
|
if ($independ) {
|
|
eq('none', $level, "$id se declara independiente y su nivel debe ser none");
|
|
eq(null, $tested, "$id independiente no puede declarar tested");
|
|
continue;
|
|
}
|
|
|
|
if ($tested !== null) {
|
|
eq('ok', $status, "$id declara tested='$tested' pero su evidencia en el reporte es '$status'");
|
|
}
|
|
}
|
|
}
|
|
});
|