mirror of
https://github.com/composer/composer
synced 2025-05-10 09:02:59 +00:00
This commit is contained in:
parent
73fd0f22e8
commit
70f2dd6edd
11 changed files with 634 additions and 13 deletions
136
tests/Composer/Test/Command/BumpCommandTest.php
Normal file
136
tests/Composer/Test/Command/BumpCommandTest.php
Normal file
|
@ -0,0 +1,136 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Test\Command;
|
||||
|
||||
use Composer\Json\JsonFile;
|
||||
use Composer\Test\TestCase;
|
||||
|
||||
class BumpCommandTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTests
|
||||
* @param array<mixed> $composerJson
|
||||
* @param array<mixed> $command
|
||||
* @param array<mixed> $expected
|
||||
*/
|
||||
public function testBump(array $composerJson, array $command, array $expected, bool $lock = true): void
|
||||
{
|
||||
$this->initTempComposer($composerJson);
|
||||
|
||||
$packages = [
|
||||
$this->getPackage('first/pkg', '2.3.4'),
|
||||
$this->getPackage('second/pkg', '3.4.0'),
|
||||
];
|
||||
$devPackages = [
|
||||
$this->getPackage('dev/pkg', '2.3.4.5'),
|
||||
];
|
||||
|
||||
$this->createInstalledJson($packages, $devPackages);
|
||||
if ($lock) {
|
||||
$this->createComposerLock($packages, $devPackages);
|
||||
}
|
||||
|
||||
$appTester = $this->getApplicationTester();
|
||||
$appTester->run(array_merge(['command' => 'bump'], $command));
|
||||
|
||||
$json = new JsonFile('./composer.json');
|
||||
$this->assertSame($expected, $json->read());
|
||||
}
|
||||
|
||||
public function provideTests(): \Generator
|
||||
{
|
||||
yield 'bump all by default' => [
|
||||
[
|
||||
'require' => [
|
||||
'first/pkg' => '^2.0',
|
||||
'second/pkg' => '3.*',
|
||||
],
|
||||
'require-dev' => [
|
||||
'dev/pkg' => '~2.0',
|
||||
],
|
||||
],
|
||||
[],
|
||||
[
|
||||
'require' => [
|
||||
'first/pkg' => '^2.3.4',
|
||||
'second/pkg' => '^3.4',
|
||||
],
|
||||
'require-dev' => [
|
||||
'dev/pkg' => '^2.3.4.5',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
yield 'bump only dev with --dev-only' => [
|
||||
[
|
||||
'require' => [
|
||||
'first/pkg' => '^2.0',
|
||||
'second/pkg' => '3.*',
|
||||
],
|
||||
'require-dev' => [
|
||||
'dev/pkg' => '~2.0',
|
||||
],
|
||||
],
|
||||
['--dev-only' => true],
|
||||
[
|
||||
'require' => [
|
||||
'first/pkg' => '^2.0',
|
||||
'second/pkg' => '3.*',
|
||||
],
|
||||
'require-dev' => [
|
||||
'dev/pkg' => '^2.3.4.5',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
yield 'bump only non-dev with --no-dev-only' => [
|
||||
[
|
||||
'require' => [
|
||||
'first/pkg' => '^2.0',
|
||||
'second/pkg' => '3.*',
|
||||
],
|
||||
'require-dev' => [
|
||||
'dev/pkg' => '~2.0',
|
||||
],
|
||||
],
|
||||
['--no-dev-only' => true],
|
||||
[
|
||||
'require' => [
|
||||
'first/pkg' => '^2.3.4',
|
||||
'second/pkg' => '^3.4',
|
||||
],
|
||||
'require-dev' => [
|
||||
'dev/pkg' => '~2.0',
|
||||
],
|
||||
]
|
||||
];
|
||||
|
||||
yield 'bump works from installed repo without lock file' => [
|
||||
[
|
||||
'require' => [
|
||||
'first/pkg' => '^2.0',
|
||||
'second/pkg' => '3.*',
|
||||
],
|
||||
],
|
||||
[],
|
||||
[
|
||||
'require' => [
|
||||
'first/pkg' => '^2.3.4',
|
||||
'second/pkg' => '^3.4',
|
||||
],
|
||||
],
|
||||
false
|
||||
];
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue