feat(compat): declare core independence with core:"none" (INDEPENDENT status, block inheritance, no warning)
This commit is contained in:
@@ -66,3 +66,67 @@ Harness::it('doctor no modifica lock ni archivos', function () {
|
||||
rrmdir($root);
|
||||
rrmdir($tool);
|
||||
});
|
||||
|
||||
Harness::it('core independiente: sin aviso en add incluso sin core conocido', function () {
|
||||
$root = tmpdir('proj');
|
||||
$tool = tmpdir('tool');
|
||||
write_file($tool . '/packages/http/duckbrain.json', json_encode([
|
||||
'name' => 'http', 'version' => '1.0.0', 'description' => 'HTTP',
|
||||
'core' => 'none',
|
||||
'components' => ['aria2' => ['files' => ['src/Libs/Aria2.php']]],
|
||||
]));
|
||||
write_file($tool . '/packages/http/src/Libs/Aria2.php', "<?php\n");
|
||||
write_file($root . '/src/Libs/Router.php', "<?php\n");
|
||||
|
||||
$lock = Lock::load($root);
|
||||
$lock->setCore(['version' => null, 'commit' => 'x', 'files' => []]);
|
||||
$lock->save($root);
|
||||
|
||||
$out = fopen('php://memory', 'rw');
|
||||
$inst = new Toolbox\Installer($root, $tool, new Console($out));
|
||||
$res = $inst->add(['http:aria2'], []);
|
||||
rewind($out);
|
||||
$text = (string) stream_get_contents($out);
|
||||
|
||||
eq([], $res['warnings'], 'independiente no produce aviso');
|
||||
eq([], $res['aborted'], 'nada se aborta');
|
||||
ok(str_contains(implode(',', $res['installed']), 'http:aria2'), 'instala normal');
|
||||
ok(!str_contains($text, 'sin datos'), 'sin ruido en consola');
|
||||
|
||||
// control: mismo fixture sin declaración sí avisa
|
||||
write_file($tool . '/packages/http/duckbrain.json', json_encode([
|
||||
'name' => 'http', 'version' => '1.0.1', 'description' => 'HTTP',
|
||||
'components' => ['aria2' => ['files' => ['src/Libs/Aria2.php']]],
|
||||
]));
|
||||
$out2 = fopen('php://memory', 'rw');
|
||||
$res2 = (new Toolbox\Installer($root, $tool, new Console($out2)))->add(['http:aria2'], ['yes' => true]);
|
||||
ok($res2['warnings'] !== [], 'sin declaración sigue avisando');
|
||||
|
||||
rrmdir($root);
|
||||
rrmdir($tool);
|
||||
});
|
||||
|
||||
Harness::it('doctor muestra independiente sin rangos y sin fallo', function () {
|
||||
$root = tmpdir('proj');
|
||||
$tool = tmpdir('tool');
|
||||
write_file($tool . '/packages/db/duckbrain.json', json_encode([
|
||||
'name' => 'db', 'version' => '1.0.0', 'description' => 'DB',
|
||||
'components' => ['sql' => ['files' => ['src/Libs/Sql.php'], 'core' => 'none']],
|
||||
]));
|
||||
write_file($tool . '/packages/db/src/Libs/Sql.php', "<?php\n");
|
||||
|
||||
$lock = Lock::load($root);
|
||||
$lock->setCore(['version' => '1.5.0', 'commit' => 'c', 'files' => []]);
|
||||
$lock->setComponent('db:sql', ['package' => 'db', 'version' => '1.0.0', 'mode' => 'copy', 'files' => []]);
|
||||
$lock->save($root);
|
||||
|
||||
$out = fopen('php://memory', 'rw');
|
||||
$code = (new DoctorCommand(new Console($out)))->run(['--root=' . $root, '--toolbox=' . $tool]);
|
||||
rewind($out);
|
||||
$text = (string) stream_get_contents($out);
|
||||
|
||||
eq(0, $code);
|
||||
ok(str_contains($text, 'INDEPENDIENTE'), 'estado independiente visible');
|
||||
rrmdir($root);
|
||||
rrmdir($tool);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user