first commit.
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
use Toolbox\Commands\AddCommand;
|
||||
use Toolbox\Commands\InstallCommand;
|
||||
use Toolbox\Console;
|
||||
use Toolbox\Lock;
|
||||
|
||||
Harness::suite('group8');
|
||||
|
||||
$GLOBALS['g8_repo'] = dirname(__DIR__);
|
||||
|
||||
Harness::it('el binario global usa el motor empaquetado en commands', function () {
|
||||
$repo = $GLOBALS['g8_repo'];
|
||||
exec('php ' . escapeshellarg($repo . '/bin/duckbrain') . ' --version 2>&1', $out, $code);
|
||||
eq(0, $code);
|
||||
ok(str_contains(implode("\n", $out), 'duckbrain-toolbox'), 'el binario global arranca');
|
||||
});
|
||||
|
||||
Harness::it('commands:toolbox es un componente opcional que se copia y hashea', function () {
|
||||
$repo = $GLOBALS['g8_repo'];
|
||||
$proj = tmpdir('proj');
|
||||
|
||||
(new AddCommand(new Console()))->run(['commands:toolbox', '--root=' . $proj, '--toolbox=' . $repo, '--yes']);
|
||||
|
||||
ok(is_file($proj . '/src/Toolbox/Installer.php'), 'motor copiado a ROOT_CORE/Toolbox');
|
||||
$lock = Lock::load($proj);
|
||||
ok($lock->has('commands:toolbox'), 'lock registra el componente opcional');
|
||||
|
||||
rrmdir($proj);
|
||||
});
|
||||
|
||||
Harness::it('el CLI del proyecto gestiona addons sin el instalador global', function () {
|
||||
$repo = $GLOBALS['g8_repo'];
|
||||
$core = g7_core('0.1.0');
|
||||
$proj = tmpdir('proj');
|
||||
|
||||
// Core + CLI + motor (todo vía el instalador global, como bootstrap).
|
||||
(new InstallCommand(new Console()))->run([$proj, '--toolbox=' . $repo, '--core-dir=' . $core, '--yes']);
|
||||
(new AddCommand(new Console()))->run(['commands:cli', 'commands:toolbox', '--root=' . $proj, '--toolbox=' . $repo, '--yes']);
|
||||
|
||||
ok(is_file($proj . '/duckbrain'), 'binario del proyecto instalado');
|
||||
|
||||
$cmd = 'cd ' . escapeshellarg($proj) . ' && php duckbrain --version 2>&1';
|
||||
exec($cmd, $out, $code);
|
||||
eq(0, $code, 'el binario del proyecto arranca: ' . implode("\n", $out));
|
||||
ok(str_contains(implode("\n", $out), 'duckbrain-toolbox'), 'usa el motor del proyecto');
|
||||
|
||||
rrmdir($proj);
|
||||
rrmdir($core);
|
||||
});
|
||||
|
||||
Harness::it('la actualización del motor surte efecto en la siguiente invocación', function () {
|
||||
$repo = $GLOBALS['g8_repo'];
|
||||
$core = g7_core('0.1.0');
|
||||
$proj = tmpdir('proj');
|
||||
|
||||
(new InstallCommand(new Console()))->run([$proj, '--toolbox=' . $repo, '--core-dir=' . $core, '--yes']);
|
||||
(new AddCommand(new Console()))->run(['commands:cli', 'commands:toolbox', '--root=' . $proj, '--toolbox=' . $repo, '--yes']);
|
||||
|
||||
$before = trim((string) shell_exec('cd ' . escapeshellarg($proj) . ' && php duckbrain --version 2>&1'));
|
||||
|
||||
// Simula una actualización del motor reescribiendo su archivo en disco.
|
||||
$config = (string) file_get_contents($proj . '/src/Toolbox/Config.php');
|
||||
$config = str_replace("VERSION = '0.1.0'", "VERSION = '0.9.9'", $config);
|
||||
write_file($proj . '/src/Toolbox/Config.php', $config);
|
||||
|
||||
$after = trim((string) shell_exec('cd ' . escapeshellarg($proj) . ' && php duckbrain --version 2>&1'));
|
||||
|
||||
ok(str_contains($before, '0.1.0'), 'antes usa la versión vieja');
|
||||
ok(str_contains($after, '0.9.9'), 'después usa la versión nueva sin recompilar');
|
||||
|
||||
rrmdir($proj);
|
||||
rrmdir($core);
|
||||
});
|
||||
Reference in New Issue
Block a user