mirror of
https://github.com/pestphp/pest.git
synced 2026-12-06 07:42:17 +01:00
fix: allow --init without a tests directory (#1939)
* fix: allow --init without a tests directory Boot aborted before TIA state was registered, and shutdown then tried to construct the plugin. That hid the real error behind "State cannot be resolved" on a fresh install. Closes #1934 * fix: detect --init anywhere in the arguments Flags before --init were still treated as a normal run and failed when tests/ did not exist. * fix: drop duplicate Kernel::$booted and share --init check 5.3.1 already gates plugin termination on boot, so the rebase must not declare $booted again. --init and --init=value now share HandleArguments::hasArgument, and the success snapshot includes the new init tests. * test: fix init suite expectations Parallel total omitted the four --init tests, which failed the success snapshot. Rector requires toBeFile(). --------- Co-authored-by: Tiago Santos <tsantos@lynixt.pt>
This commit is contained in:
@@ -17,6 +17,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*/
|
||||
final readonly class Init implements HandlesArguments
|
||||
{
|
||||
use Concerns\HandleArguments;
|
||||
|
||||
private const string INIT_OPTION = '--init';
|
||||
|
||||
private const array STUBS = [
|
||||
@@ -40,14 +42,9 @@ final readonly class Init implements HandlesArguments
|
||||
*/
|
||||
public function handleArguments(array $arguments): array
|
||||
{
|
||||
if (! array_key_exists(1, $arguments)) {
|
||||
if (! $this->hasArgument(self::INIT_OPTION, $arguments)) {
|
||||
return $arguments;
|
||||
}
|
||||
if ($arguments[1] !== self::INIT_OPTION) {
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
unset($arguments[1]);
|
||||
|
||||
$this->init();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user