fix(cli): adopt core records canonical hashes and flags local edits
This commit is contained in:
@@ -121,3 +121,31 @@ Harness::it('adopt registra el core existente con sus hashes', function () {
|
||||
rrmdir($proj);
|
||||
rrmdir($core);
|
||||
});
|
||||
|
||||
Harness::it('adopt del core registra hash canónico y marca ediciones locales', function () {
|
||||
$repo = $GLOBALS['g9_repo'];
|
||||
$core = g7_core('0.1.0');
|
||||
$proj = tmpdir('proj');
|
||||
|
||||
// Copia idéntica de Router.php + config.php customizado (proyecto heredado).
|
||||
write_file($proj . '/src/Libs/Router.php', (string) file_get_contents($core . '/src/Libs/Router.php'));
|
||||
write_file($proj . '/config.php', "<?php\n// credenciales del proyecto\n");
|
||||
|
||||
(new AdoptCommand(new Console()))->run(['--root=' . $proj, '--toolbox=' . $repo, '--core-dir=' . $core]);
|
||||
|
||||
$lock = Lock::load($proj);
|
||||
$coreHashRouter = $lock->core()['files']['src/Libs/Router.php'];
|
||||
$coreHashConfig = $lock->core()['files']['config.php'];
|
||||
|
||||
$canonicalRouter = (string) file_get_contents($core . '/src/Libs/Router.php');
|
||||
$canonicalConfig = (string) file_get_contents($core . '/config.php');
|
||||
|
||||
eq('sha256:' . hash('sha256', $canonicalRouter), $coreHashRouter, 'hash de Router.php = canónico');
|
||||
eq('sha256:' . hash('sha256', $canonicalConfig), $coreHashConfig, 'hash de config.php = canónico (aunque el local difiera)');
|
||||
eq('local', $lock->core()['origin'] ?? null, 'origin = local porque hay ediciones locales');
|
||||
|
||||
ok(file_get_contents($proj . '/config.php') !== $canonicalConfig, 'la copia local customizada no se tocó');
|
||||
|
||||
rrmdir($proj);
|
||||
rrmdir($core);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user