Skip to content

Commit 870cd17

Browse files
committed
[tests] Fix no-logo option handling and assertions
1 parent d4b4a06 commit 870cd17

3 files changed

Lines changed: 15 additions & 30 deletions

File tree

src/Console/DevTools.php

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
*/
4848
final class DevTools extends Application
4949
{
50-
private const string NO_LOGO_OPTION = 'no-logo';
51-
5250
private const string LOGO = <<<'LOGO'
5351
____ _____ _
5452
| _ \ _____ _|_ _|__ ___ | |___
@@ -57,6 +55,8 @@ final class DevTools extends Application
5755
|____/ \___| \_/ |_|\___/ \___/|_|___/
5856
LOGO;
5957

58+
private const string NO_LOGO_OPTION = 'no-logo';
59+
6060
/**
6161
* @var ContainerInterface holds the static container instance for global access within the DevTools context
6262
*/
@@ -89,16 +89,6 @@ public function __construct(
8989
$this->setCommandLoader($commandLoader);
9090
}
9191

92-
/**
93-
* Gets the help message for the DevTools application.
94-
*
95-
*/
96-
#[Override]
97-
public function getHelp(): string
98-
{
99-
return parent::getHelp();
100-
}
101-
10292
/**
10393
* Returns the application-level input definition with DevTools runtime options.
10494
*
@@ -130,7 +120,7 @@ protected function getDefaultInputDefinition(): InputDefinition
130120
));
131121

132122
$definition->addOption(new InputOption(
133-
name: self::NO_LOGO_OPTION,
123+
name: 'no-logo',
134124
mode: InputOption::VALUE_NONE,
135125
description: 'Hide the startup ASCII logo.',
136126
));
@@ -149,7 +139,9 @@ protected function getDefaultInputDefinition(): InputDefinition
149139
#[Override]
150140
public function doRun(InputInterface $input, OutputInterface $output): int
151141
{
152-
if (! (bool) $input->getOption(self::NO_LOGO_OPTION)) {
142+
$noLogo = (bool) $input->getParameterOption('--no-logo', null, true);
143+
144+
if (! $noLogo) {
153145
$output->writeln(self::LOGO);
154146
}
155147

@@ -162,7 +154,7 @@ public function doRun(InputInterface $input, OutputInterface $output): int
162154
return Command::FAILURE;
163155
}
164156

165-
if (! $this->isSelfUpdateCommand($input)) {
157+
if (! $noLogo && ! $this->isSelfUpdateCommand($input)) {
166158
$this->runAutoUpdateWhenRequested($input, $output);
167159
$this->versionCheckNotifier->notify($output);
168160
}

src/Process/ProcessBuilder.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,14 @@ private function shouldAddLogoSuppressionArgument(array $command): bool
121121
return false;
122122
}
123123

124-
if (0 === \count($command)) {
124+
if ([] === $command) {
125125
return false;
126126
}
127127

128-
$binary = \str_replace('\\', '/', $command[0]);
129-
$packageBinaryPath = \str_replace('\\', '/', DevToolsPathResolver::getBinaryPath());
130-
131-
return $binary === $packageBinaryPath
132-
|| \str_starts_with($binary, 'vendor/bin/dev-tools')
133-
|| \str_starts_with($binary, './vendor/bin/dev-tools')
134-
|| \str_starts_with($binary, 'bin/dev-tools')
135-
|| \str_starts_with($binary, './bin/dev-tools')
136-
|| \str_ends_with($binary, '/vendor/bin/dev-tools')
137-
|| \str_ends_with($binary, '/vendor/fast-forward/dev-tools/bin/dev-tools')
138-
|| \str_ends_with($binary, '/bin/dev-tools');
128+
$binary = str_replace('\\', '/', $command[0]);
129+
$packageBinaryPath = str_replace('\\', '/', DevToolsPathResolver::getBinaryPath());
130+
131+
return $binary === $packageBinaryPath;
139132
}
140133

141134
/**
@@ -145,11 +138,11 @@ private function shouldAddLogoSuppressionArgument(array $command): bool
145138
*/
146139
private function prependLogoSuppressionArgument(array $command): array
147140
{
148-
if (0 === \count($command)) {
141+
if ([] === $command) {
149142
return $command;
150143
}
151144

152-
$binary = \array_shift($command);
145+
$binary = array_shift($command);
153146

154147
return [$binary, self::NO_LOGO_ARGUMENT, ...$command];
155148
}

tests/Console/DevToolsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public function constructorWillRegisterGlobalRuntimeOptions(): void
218218
self::assertSame('w', $definition->getOption('workspace-dir')->getShortcut());
219219
self::assertTrue($definition->hasOption('auto-update'));
220220
self::assertTrue($definition->hasOption('no-logo'));
221-
self::assertFalse($definition->getOption('no-logo')->acceptsValue());
221+
self::assertFalse($definition->getOption('no-logo')->acceptValue());
222222
}
223223

224224
/**

0 commit comments

Comments
 (0)