Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public function execute(InputInterface $input, OutputInterface $output): int
return self::INVALID;
}

if ($installFromLock && CommandHelper::noDev($input)) {
$this->io->writeError('<warning>The --no-dev option has no effect when used with --from-lock; all extensions in the lock file will be installed.</warning>');
}

if (! $installFromLock && ! $input->getArgument(CommandHelper::ARG_REQUESTED_PACKAGE_AND_VERSION)) {
return ($this->invokeSubCommand)(
$this,
Expand Down
38 changes: 38 additions & 0 deletions test/unit/Command/InstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@

namespace Php\PieUnitTest\Command;

use Composer\IO\BufferIO;
use Php\Pie\Command\InstallCommand;
use Php\Pie\Command\InvokeSubCommand;
use Php\Pie\ComposerIntegration\ComposerIntegrationHandler;
use Php\Pie\Container;
use Php\Pie\DependencyResolver\DependencyInstaller\PrescanSystemDependencies;
use Php\Pie\DependencyResolver\DependencyResolver;
use Php\Pie\Installing\InstallForPhpProject\FindMatchingPackages;
use Php\Pie\SelfManage\BuildTools\CheckAllBuildTools;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Tester\CommandTester;

#[CoversClass(InstallCommand::class)]
final class InstallCommandTest extends TestCase
Expand All @@ -19,4 +27,34 @@ public function testFromLockOptionExistsOnInstallCommand(): void

self::assertTrue($definition->hasOption(InstallCommand::OPTION_FROM_LOCK));
}

public function testNoDevWithFromLockWarnsThatNoDevHasNoEffect(): void
{
$io = new BufferIO();

$composerIntegrationHandler = $this->createMock(ComposerIntegrationHandler::class);
$composerIntegrationHandler->expects(self::once())->method('runInstall');

$commandTester = new CommandTester(new InstallCommand(
Container::testFactory(),
$this->createMock(DependencyResolver::class),
$this->createMock(PrescanSystemDependencies::class),
$composerIntegrationHandler,
$this->createMock(InvokeSubCommand::class),
$this->createMock(FindMatchingPackages::class),
$io,
$this->createMock(CheckAllBuildTools::class),
));

$commandTester->execute([
'--from-lock' => true,
'--no-dev' => true,
]);

$commandTester->assertCommandIsSuccessful();
self::assertStringContainsString(
'The --no-dev option has no effect when used with --from-lock',
$io->getOutput(),
);
}
}
Loading