Skip to content

Commit

Permalink
Merge pull request #5 from edersoares/composer-breaking-changes
Browse files Browse the repository at this point in the history
Composer breaking changes
  • Loading branch information
edersoares committed Oct 6, 2021
2 parents 661cfa9 + aa36122 commit bc9d85a
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 79 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -21,15 +21,15 @@ Now, you can create or clone a [Composer](https://getcomposer.org/) package into
and run:

```bash
composer install --plug-and-play
composer plug-and-play:install

# or

composer update --plug-and-play
composer plug-and-play:update

# or

composer dump-autoload --plug-and-play
composer plug-and-play:dump
```

### Directories and files
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -16,7 +16,7 @@
"composer-plugin-api": "^2.0"
},
"require-dev": {
"composer/composer": "<=2.1.5",
"composer/composer": "^2.0",
"phpunit/phpunit": "^9.4"
},
"autoload": {
Expand Down
5 changes: 1 addition & 4 deletions src/Commands/CommandNaming.php
Expand Up @@ -10,15 +10,12 @@ trait CommandNaming
* Define name, aliases and add plug and play option.
*
* @param string $command
* @param array $aliases
*
* @return void
*/
public function naming(string $command, array $aliases = [])
public function naming(string $command)
{
$this->setName($command);
$this->setAliases($aliases);
$this->addOption('plug-and-play', null, InputOption::VALUE_NONE, 'Run using plug and play plugin.');
$this->addOption('plug-and-play-pretend', null, InputOption::VALUE_NONE, 'Run pretending to use plug and play plugin.');
}
}
3 changes: 1 addition & 2 deletions src/Commands/ComposerCreator.php
Expand Up @@ -69,9 +69,8 @@ public function getComposer($required = true, $disablePlugins = null)
protected function execute(InputInterface $input, OutputInterface $output)
{
$isTheCommand = $input->getFirstArgument() === $this->getName();
$hasOption = $input->getOption('plug-and-play');

if ($isTheCommand || $hasOption) {
if ($isTheCommand) {
$this->usePlugAndPlay = true;
$output->writeln('<info>You are using Composer Plug and Play Plugin.</info>');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/DumpAutoloadCommand.php
Expand Up @@ -12,6 +12,6 @@ protected function configure()
{
parent::configure();

$this->naming('plug-and-play:dump', ['dumpautoload', 'dump-autoload']);
$this->naming('plug-and-play:dump');
}
}
2 changes: 1 addition & 1 deletion src/Commands/InstallCommand.php
Expand Up @@ -12,6 +12,6 @@ protected function configure()
{
parent::configure();

$this->naming('plug-and-play:install', ['i', 'install']);
$this->naming('plug-and-play:install');
}
}
2 changes: 1 addition & 1 deletion src/Commands/UpdateCommand.php
Expand Up @@ -12,6 +12,6 @@ protected function configure()
{
parent::configure();

$this->naming('plug-and-play:update', ['u', 'update']);
$this->naming('plug-and-play:update');
}
}
66 changes: 0 additions & 66 deletions tests/Unit/ComposerCommandsTest.php
Expand Up @@ -61,70 +61,4 @@ public function testListCommand()
$this->assertStringContainsString('plug-and-play:install', $content);
$this->assertStringContainsString('plug-and-play:update', $content);
}

public function testInstallCommand()
{
$application = new Application();
$input = new StringInput("install --plug-and-play --plug-and-play-pretend -d {$this->directory}");
$output = new BufferedOutput();

$application->doRun($input, $output);

$this->assertStringContainsString('You are using Composer Plug and Play Plugin.', $output->fetch());
}

public function testUpdateCommand()
{
$application = new Application();
$input = new StringInput("update --plug-and-play --plug-and-play-pretend -d {$this->directory}");
$output = new BufferedOutput();

$application->doRun($input, $output);

$this->assertStringContainsString('You are using Composer Plug and Play Plugin.', $output->fetch());
}

public function testDumpautoloadCommand()
{
$application = new Application();
$input = new StringInput("dumpautoload --plug-and-play --plug-and-play-pretend -d {$this->directory}");
$output = new BufferedOutput();

$application->doRun($input, $output);

$this->assertStringContainsString('You are using Composer Plug and Play Plugin.', $output->fetch());
}

public function testIfOptionIsPresentInInstallCommand()
{
$application = new Application();
$input = new StringInput("install --help -d {$this->directory}");
$output = new BufferedOutput();

$application->doRun($input, $output);

$this->assertStringContainsString('--plug-and-play', $output->fetch());
}

public function testIfOptionIsPresentInUpdateCommand()
{
$application = new Application();
$input = new StringInput("update --help -d {$this->directory}");
$output = new BufferedOutput();

$application->doRun($input, $output);

$this->assertStringContainsString('--plug-and-play', $output->fetch());
}

public function testIfOptionIsPresentInDumpautoloadCommand()
{
$application = new Application();
$input = new StringInput("dumpautoload --help -d {$this->directory}");
$output = new BufferedOutput();

$application->doRun($input, $output);

$this->assertStringContainsString('--plug-and-play', $output->fetch());
}
}

0 comments on commit bc9d85a

Please sign in to comment.