diff --git a/src/Installing/SetupIniFile.php b/src/Installing/SetupIniFile.php
index c1e0f487..d4d464ae 100644
--- a/src/Installing/SetupIniFile.php
+++ b/src/Installing/SetupIniFile.php
@@ -39,11 +39,9 @@ public function __invoke(
$downloadedPackage->package->prettyNameAndVersion(),
$targetPlatform->phpBinaryPath->phpBinaryPath,
));
+ } elseif (! $attemptToSetupIniFile) {
+ $io->write('Automatic extension enabling was skipped.', verbosity: IOInterface::VERBOSE);
} else {
- if (! $attemptToSetupIniFile) {
- $io->write('Automatic extension enabling was skipped.', verbosity: IOInterface::VERY_VERBOSE);
- }
-
$io->write(sprintf('%s Extension has NOT been automatically enabled.', Emoji::WARNING));
$io->write(sprintf(
'You must now add "%s=%s" to your php.ini',
diff --git a/test/behaviour/CliContext.php b/test/behaviour/CliContext.php
index 8bf22c11..204172e6 100644
--- a/test/behaviour/CliContext.php
+++ b/test/behaviour/CliContext.php
@@ -250,7 +250,7 @@ public function iRunACommandToForcefullyInstallAnExtension(): void
public function iRunACommandToInstallAnExtensionWithoutEnabling(): void
{
$this->interactions[] = ['extension' => 'example_pie_extension', 'package' => 'asgrim/example-pie-extension'];
- $this->runPieCommand(['install', 'asgrim/example-pie-extension', '--skip-enable-extension']);
+ $this->runPieCommand(['install', 'asgrim/example-pie-extension', '--skip-enable-extension', '-v']);
}
#[When('I run a command to uninstall an extension')]
@@ -297,7 +297,9 @@ public function theExtensionShouldHaveBeenInstalled(): void
{
$this->assertCommandSuccessful();
- Assert::contains($this->output, 'Extension has NOT been automatically enabled.');
+ Assert::contains($this->output, 'Automatic extension enabling was skipped.');
+ Assert::notContains($this->output, 'Extension has NOT been automatically enabled.');
+ Assert::notContains($this->output, 'You must now add');
foreach ($this->interactions as $install) {
if (Platform::isWindows()) {
diff --git a/test/integration/Command/InstallCommandTest.php b/test/integration/Command/InstallCommandTest.php
index 027c706e..c6e8bfef 100644
--- a/test/integration/Command/InstallCommandTest.php
+++ b/test/integration/Command/InstallCommandTest.php
@@ -111,7 +111,7 @@ public function testInstallCommandWillInstallCompatibleExtensionNonWindows(strin
}
self::assertStringContainsString('Install complete: ', $outputString);
- self::assertStringContainsString('You must now add "extension=example_pie_extension" to your php.ini', $outputString);
+ self::assertStringNotContainsString('You must now add "extension=example_pie_extension" to your php.ini', $outputString);
}
#[RequiresOperatingSystemFamily('Windows')]
@@ -135,6 +135,6 @@ public function testInstallCommandWillInstallCompatibleExtensionWindows(): void
}
self::assertStringContainsString('Copied DLL to: ', $outputString);
- self::assertStringContainsString('You must now add "extension=example_pie_extension" to your php.ini', $outputString);
+ self::assertStringNotContainsString('You must now add "extension=example_pie_extension" to your php.ini', $outputString);
}
}
diff --git a/test/unit/Installing/SetupIniFileTest.php b/test/unit/Installing/SetupIniFileTest.php
new file mode 100644
index 00000000..5758ad29
--- /dev/null
+++ b/test/unit/Installing/SetupIniFileTest.php
@@ -0,0 +1,133 @@
+createMock(CompletePackageInterface::class),
+ ExtensionType::PhpModule,
+ ExtensionName::normaliseFromString('xdebug'),
+ 'foo/bar',
+ '1.2.3',
+ null,
+ );
+
+ $this->downloadedPackage = DownloadedPackage::fromPackageAndExtractedPath($package, __DIR__);
+ $this->binaryFile = new BinaryFile(__FILE__, 'abc123');
+
+ $phpBinaryPath = $this->createMock(PhpBinaryPath::class);
+ /** @phpstan-ignore property.notFound */
+ (fn () => $this->phpBinaryPath = '/usr/bin/php')
+ ->bindTo($phpBinaryPath, PhpBinaryPath::class)();
+
+ $this->targetPlatform = new TargetPlatform(
+ OperatingSystem::NonWindows,
+ OperatingSystemFamily::Linux,
+ $phpBinaryPath,
+ Architecture::x86_64,
+ ThreadSafetyMode::NonThreadSafe,
+ 1,
+ null,
+ null,
+ );
+ }
+
+ public function testSuccessfulSetupPrintsEnabledMessage(): void
+ {
+ $setupIniApproach = $this->createMock(SetupIniApproach::class);
+ $setupIniApproach->method('canBeUsed')->willReturn(true);
+ $setupIniApproach->method('setup')->willReturn(true);
+
+ $io = new BufferIO();
+
+ (new SetupIniFile($setupIniApproach))(
+ $this->targetPlatform,
+ $this->downloadedPackage,
+ $this->binaryFile,
+ $io,
+ true,
+ );
+
+ $output = $io->getOutput();
+
+ self::assertStringContainsString('is enabled and loaded in', $output);
+ self::assertStringNotContainsString('Extension has NOT been automatically enabled.', $output);
+ self::assertStringNotContainsString('Automatic extension enabling was skipped.', $output);
+ }
+
+ public function testDeliberateSkipDoesNotPrintWarning(): void
+ {
+ $setupIniApproach = $this->createMock(SetupIniApproach::class);
+ $setupIniApproach->expects(self::never())->method('canBeUsed');
+ $setupIniApproach->expects(self::never())->method('setup');
+
+ $io = new BufferIO('', StreamOutput::VERBOSITY_VERBOSE);
+
+ (new SetupIniFile($setupIniApproach))(
+ $this->targetPlatform,
+ $this->downloadedPackage,
+ $this->binaryFile,
+ $io,
+ false,
+ );
+
+ $output = $io->getOutput();
+
+ self::assertStringContainsString('Automatic extension enabling was skipped.', $output);
+ self::assertStringNotContainsString('Extension has NOT been automatically enabled.', $output);
+ self::assertStringNotContainsString('You must now add', $output);
+ }
+
+ public function testAttemptedButFailedSetupPrintsWarning(): void
+ {
+ $setupIniApproach = $this->createMock(SetupIniApproach::class);
+ $setupIniApproach->method('canBeUsed')->willReturn(false);
+
+ $io = new BufferIO();
+
+ (new SetupIniFile($setupIniApproach))(
+ $this->targetPlatform,
+ $this->downloadedPackage,
+ $this->binaryFile,
+ $io,
+ true,
+ );
+
+ $output = $io->getOutput();
+
+ self::assertStringContainsString('Extension has NOT been automatically enabled.', $output);
+ self::assertStringContainsString('You must now add "extension=xdebug" to your php.ini', $output);
+ self::assertStringNotContainsString('Automatic extension enabling was skipped.', $output);
+ }
+}