mirror of
https://github.com/composer/composer
synced 2025-05-10 00:53:06 +00:00
parent
58905ffe4e
commit
3a2a18175d
3 changed files with 87 additions and 20 deletions
|
@ -19,49 +19,70 @@ class ReinstallCommandTest extends TestCase
|
|||
{
|
||||
/**
|
||||
* @dataProvider caseProvider
|
||||
* @param array<string> $packages
|
||||
* @param array<mixed> $options
|
||||
* @param string $expected
|
||||
*/
|
||||
public function testReinstallCommand(array $packages, string $expected): void
|
||||
public function testReinstallCommand(array $options, string $expected): void
|
||||
{
|
||||
$this->initTempComposer([
|
||||
'require' => [
|
||||
'root/req' => '1.*',
|
||||
'root/anotherreq' => '2.*'
|
||||
],
|
||||
'require-dev' => [
|
||||
'root/anotherreq' => '2.*',
|
||||
'root/anotherreq2' => '2.*',
|
||||
'root/lala' => '2.*',
|
||||
]
|
||||
]);
|
||||
|
||||
$rootReqPackage = self::getPackage('root/req');
|
||||
$anotherReqPackage = self::getPackage('root/anotherreq');
|
||||
$anotherReqPackage2 = self::getPackage('root/anotherreq2');
|
||||
$anotherReqPackage3 = self::getPackage('root/lala');
|
||||
$rootReqPackage->setType('metapackage');
|
||||
$anotherReqPackage->setType('metapackage');
|
||||
$anotherReqPackage2->setType('metapackage');
|
||||
$anotherReqPackage3->setType('metapackage');
|
||||
|
||||
$this->createComposerLock([$rootReqPackage], [$anotherReqPackage]);
|
||||
$this->createInstalledJson([$rootReqPackage], [$anotherReqPackage]);
|
||||
$this->createComposerLock([$rootReqPackage], [$anotherReqPackage, $anotherReqPackage2, $anotherReqPackage3]);
|
||||
$this->createInstalledJson([$rootReqPackage], [$anotherReqPackage, $anotherReqPackage2, $anotherReqPackage3]);
|
||||
|
||||
$appTester = $this->getApplicationTester();
|
||||
$appTester->run([
|
||||
$appTester->run(array_merge([
|
||||
'command' => 'reinstall',
|
||||
'--no-progress' => true,
|
||||
'--no-plugins' => true,
|
||||
'packages' => $packages
|
||||
]);
|
||||
], $options));
|
||||
|
||||
self::assertSame($expected, trim($appTester->getDisplay(true)));
|
||||
}
|
||||
|
||||
public function caseProvider(): Generator
|
||||
{
|
||||
yield 'reinstall a package' => [
|
||||
['root/req', 'root/anotherreq'],
|
||||
yield 'reinstall a package by name' => [
|
||||
['packages' => ['root/req', 'root/anotherreq*']],
|
||||
'- Removing root/req (1.0.0)
|
||||
- Removing root/anotherreq2 (1.0.0)
|
||||
- Removing root/anotherreq (1.0.0)
|
||||
- Installing root/anotherreq (1.0.0)
|
||||
- Installing root/anotherreq2 (1.0.0)
|
||||
- Installing root/req (1.0.0)'
|
||||
];
|
||||
|
||||
yield 'reinstall packages by type' => [
|
||||
['--type' => ['metapackage']],
|
||||
'- Removing root/req (1.0.0)
|
||||
- Removing root/lala (1.0.0)
|
||||
- Removing root/anotherreq2 (1.0.0)
|
||||
- Removing root/anotherreq (1.0.0)
|
||||
- Installing root/anotherreq (1.0.0)
|
||||
- Installing root/anotherreq2 (1.0.0)
|
||||
- Installing root/lala (1.0.0)
|
||||
- Installing root/req (1.0.0)'
|
||||
];
|
||||
|
||||
yield 'reinstall a package that is not installed' => [
|
||||
['root/unknownreq'],
|
||||
['packages' => ['root/unknownreq']],
|
||||
'<warning>Pattern "root/unknownreq" does not match any currently installed packages.</warning>
|
||||
<warning>Found no packages to reinstall, aborting.</warning>'
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue