Add Update Interactive tests (#12065)
* Add Update Interactive tests * Fix type + remove extra comma * Used `php-cs-fixer` * Normalize for windows + fix use of `Generator`pull/12091/head
parent
8715c7b8d6
commit
47b924d27c
|
@ -12,6 +12,8 @@
|
|||
|
||||
namespace Composer\Test\Command;
|
||||
|
||||
use Composer\Package\Link;
|
||||
use Composer\Semver\Constraint\MatchAllConstraint;
|
||||
use Composer\Test\TestCase;
|
||||
use InvalidArgumentException;
|
||||
|
||||
|
@ -135,4 +137,97 @@ OUTPUT
|
|||
$appTester->setInputs(['']);
|
||||
$appTester->run(['command' => 'update', '--interactive' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideInteractiveUpdates
|
||||
* @param array<mixed> $packageNames
|
||||
*/
|
||||
public function testInteractiveTmp(array $packageNames, string $expected): void
|
||||
{
|
||||
$this->initTempComposer([
|
||||
'repositories' => [
|
||||
'packages' => [
|
||||
'type' => 'package',
|
||||
'package' => [
|
||||
['name' => 'root/req', 'version' => '1.0.0', 'require' => ['dep/pkg' => '^1']],
|
||||
['name' => 'dep/pkg', 'version' => '1.0.0'],
|
||||
['name' => 'dep/pkg', 'version' => '1.0.1'],
|
||||
['name' => 'dep/pkg', 'version' => '1.0.2'],
|
||||
['name' => 'another-dep/pkg', 'version' => '1.0.2'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'require' => [
|
||||
'root/req' => '1.*',
|
||||
],
|
||||
]);
|
||||
|
||||
$rootPackage = self::getPackage('root/req');
|
||||
$packages = [$rootPackage];
|
||||
|
||||
foreach ($packageNames as $pkg => $ver) {
|
||||
$currentPkg = self::getPackage($pkg, $ver);
|
||||
array_push($packages, $currentPkg);
|
||||
}
|
||||
|
||||
$rootPackage->setRequires([
|
||||
'dep/pkg' => new Link(
|
||||
'root/req',
|
||||
'dep/pkg',
|
||||
new MatchAllConstraint(),
|
||||
Link::TYPE_REQUIRE,
|
||||
'^1'
|
||||
),
|
||||
'another-dep/pkg' => new Link(
|
||||
'root/req',
|
||||
'another-dep/pkg',
|
||||
new MatchAllConstraint(),
|
||||
Link::TYPE_REQUIRE,
|
||||
'^1'
|
||||
),
|
||||
]);
|
||||
|
||||
$this->createComposerLock($packages);
|
||||
$this->createInstalledJson($packages);
|
||||
|
||||
$appTester = $this->getApplicationTester();
|
||||
$appTester->setInputs(array_merge(array_keys($packageNames), ['', 'yes']));
|
||||
$appTester->run([
|
||||
'command' => 'update', '--interactive' => true,
|
||||
'--no-audit' => true,
|
||||
'--dry-run' => true,
|
||||
]);
|
||||
|
||||
self::assertStringEndsWith(
|
||||
trim($expected),
|
||||
trim($appTester->getDisplay(true))
|
||||
);
|
||||
}
|
||||
|
||||
public function provideInteractiveUpdates(): \Generator
|
||||
{
|
||||
yield [
|
||||
['dep/pkg' => '1.0.1'],
|
||||
<<<OUTPUT
|
||||
Lock file operations: 1 install, 1 update, 0 removals
|
||||
- Locking another-dep/pkg (1.0.2)
|
||||
- Upgrading dep/pkg (1.0.1 => 1.0.2)
|
||||
Installing dependencies from lock file (including require-dev)
|
||||
Package operations: 1 install, 1 update, 0 removals
|
||||
- Upgrading dep/pkg (1.0.1 => 1.0.2)
|
||||
- Installing another-dep/pkg (1.0.2)
|
||||
OUTPUT
|
||||
];
|
||||
|
||||
yield [
|
||||
['dep/pkg' => '1.0.1', 'another-dep/pkg' => '1.0.2'],
|
||||
<<<OUTPUT
|
||||
Lock file operations: 0 installs, 1 update, 0 removals
|
||||
- Upgrading dep/pkg (1.0.1 => 1.0.2)
|
||||
Installing dependencies from lock file (including require-dev)
|
||||
Package operations: 0 installs, 1 update, 0 removals
|
||||
- Upgrading dep/pkg (1.0.1 => 1.0.2)
|
||||
OUTPUT
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue