Skip to content

Commit

Permalink
Merge pull request #3 from YouweGit/feature/OTDEVOPS-18-coding-standards
Browse files Browse the repository at this point in the history
Add option to update module with all dependencies.
  • Loading branch information
leonhelmus authored Oct 27, 2022
2 parents 0ee994d + 5cd1bce commit 7ba051b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 1.4.0
### Added
- Option to update module with all dependencies.

## 1.3.1
### Changed
- Package is now also installable in PHP 8.
Expand Down
6 changes: 4 additions & 2 deletions src/DependencyInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ public function installRepository(string $name, string $type, string $url)
*
* @param string $name
* @param string $version
* @param bool $dev
* @param bool $dev
* @param bool $updateDependencies
*
* @return void
*
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function installPackage(string $name, string $version, bool $dev = true)
public function installPackage(string $name, string $version, bool $dev = true, bool $updateDependencies = false)
{
$node = $dev ? 'require-dev' : 'require';

Expand All @@ -126,6 +127,7 @@ public function installPackage(string $name, string $version, bool $dev = true)
'command' => 'require',
'packages' => [$name . ':' . $version],
'--dev' => $dev,
'-W' => $updateDependencies,
'--no-scripts' => true,
'--no-interaction' => true,
'--no-plugins' => true,
Expand Down
16 changes: 10 additions & 6 deletions tests/DependencyInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Youwe\Composer\DependencyInstaller\Tests;

use Composer\Json\JsonFile;
use Seld\JsonLint\ParsingException;
use Youwe\Composer\DependencyInstaller\DependencyInstaller;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -131,21 +132,24 @@ public function repositoryProvider(): array
* @depends testConstructor
* @dataProvider packageProvider
*
* @param string $name
* @param string $version
* @param bool $dev
* @param string $name
* @param string $version
* @param bool $dev
* @param bool $updateDependencies
* @param DependencyInstaller $dependencyInstaller
*
* @return void
* @throws ParsingException
* @covers ::installPackage
*/
public function testInstallPackage(
string $name,
string $version,
bool $dev,
bool $updateDependencies,
DependencyInstaller $dependencyInstaller
) {
$dependencyInstaller->installPackage($name, $version, $dev);
$dependencyInstaller->installPackage($name, $version, $dev, $updateDependencies);

$jsonFile = new JsonFile('composer.json');
$definition = $jsonFile->read();
Expand All @@ -163,8 +167,8 @@ public function testInstallPackage(
public function packageProvider(): array
{
return [
['psr/log', '@stable', true],
['psr/log', '@stable', false]
['psr/log', '@stable', true, false],
['psr/log', '@stable', false, false]
];
}
}

0 comments on commit 7ba051b

Please sign in to comment.