Update tests
parent
754f2868fb
commit
df8f9f05a3
|
@ -228,7 +228,7 @@ class BaseDependencyCommandTest extends TestCase
|
|||
*
|
||||
* @param array<string, string|bool> $parameters
|
||||
*/
|
||||
public function testWhyCommandOutputs(array $parameters, string $expectedOutput): void
|
||||
public function testWhyCommandOutputs(array $parameters, string $expectedOutput, int $expectedStatusCode): void
|
||||
{
|
||||
$packageToBeInspected = $parameters['package'];
|
||||
$renderAsTree = $parameters['--tree'] ?? false;
|
||||
|
@ -294,9 +294,9 @@ class BaseDependencyCommandTest extends TestCase
|
|||
'--locked' => true
|
||||
]);
|
||||
|
||||
$appTester->assertCommandIsSuccessful();
|
||||
self::assertSame($expectedStatusCode, $appTester->getStatusCode());
|
||||
|
||||
$this->assertEquals(trim($expectedOutput), trim($appTester->getDisplay(true)));
|
||||
$this->assertEquals(trim($expectedOutput), $this->trimLines($appTester->getDisplay(true)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,7 +306,8 @@ class BaseDependencyCommandTest extends TestCase
|
|||
{
|
||||
yield 'there is no installed package depending on the package' => [
|
||||
['package' => 'vendor1/package1'],
|
||||
'There is no installed package depending on "vendor1/package1"'
|
||||
'There is no installed package depending on "vendor1/package1"',
|
||||
1
|
||||
];
|
||||
|
||||
yield 'a nested package dependency' => [
|
||||
|
@ -314,7 +315,8 @@ class BaseDependencyCommandTest extends TestCase
|
|||
<<<OUTPUT
|
||||
__root__ - requires vendor1/package3 (2.3.0)
|
||||
vendor1/package2 2.3.0 requires vendor1/package3 (^1)
|
||||
OUTPUT
|
||||
OUTPUT,
|
||||
0
|
||||
];
|
||||
|
||||
yield 'a nested package dependency (tree mode)' => [
|
||||
|
@ -325,7 +327,8 @@ vendor1/package3 2.1.0
|
|||
`--vendor1/package2 2.3.0 (requires vendor1/package3 ^1)
|
||||
|--__root__ (requires vendor1/package2 1.3.0)
|
||||
`--vendor1/package1 1.3.0 (requires vendor1/package2 ^2)
|
||||
OUTPUT
|
||||
OUTPUT,
|
||||
0
|
||||
];
|
||||
|
||||
yield 'a nested package dependency (recursive mode)' => [
|
||||
|
@ -335,12 +338,14 @@ __root__ - requires vendor1/package2 (1.3.0)
|
|||
vendor1/package1 1.3.0 requires vendor1/package2 (^2)
|
||||
__root__ - requires vendor1/package3 (2.3.0)
|
||||
vendor1/package2 2.3.0 requires vendor1/package3 (^1)
|
||||
OUTPUT
|
||||
OUTPUT,
|
||||
0
|
||||
];
|
||||
|
||||
yield 'a simple package dev dependency' => [
|
||||
['package' => 'vendor2/package1'],
|
||||
'__root__ - requires (for development) vendor2/package1 (2.*)'
|
||||
'__root__ - requires (for development) vendor2/package1 (2.*)',
|
||||
0
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -354,7 +359,7 @@ OUTPUT
|
|||
*
|
||||
* @param array<string, string> $parameters
|
||||
*/
|
||||
public function testWhyNotCommandOutputs(array $parameters, string $expectedOutput): void
|
||||
public function testWhyNotCommandOutputs(array $parameters, string $expectedOutput, int $expectedStatusCode): void
|
||||
{
|
||||
$packageToBeInspected = $parameters['package'];
|
||||
$packageVersionToBeInspected = $parameters['version'];
|
||||
|
@ -411,8 +416,8 @@ OUTPUT
|
|||
'version' => $packageVersionToBeInspected
|
||||
]);
|
||||
|
||||
$appTester->assertCommandIsSuccessful();
|
||||
$this->assertSame(trim($expectedOutput), trim($appTester->getDisplay(true)));
|
||||
self::assertSame($expectedStatusCode, $appTester->getStatusCode());
|
||||
$this->assertSame(trim($expectedOutput), $this->trimLines($appTester->getDisplay(true)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -426,7 +431,8 @@ OUTPUT
|
|||
Package "vendor1/package1" could not be found with constraint "3.*", results below will most likely be incomplete.
|
||||
__root__ - requires vendor1/package1 (1.*)
|
||||
Not finding what you were looking for? Try calling `composer require "vendor1/package1:3.*" --dry-run` to get another view on the problem.
|
||||
OUTPUT
|
||||
OUTPUT,
|
||||
1
|
||||
];
|
||||
|
||||
yield 'it could not found the package and there is no installed package with a specific version' => [
|
||||
|
@ -435,7 +441,8 @@ OUTPUT
|
|||
Package "vendor1/package1" could not be found with constraint "^1.4", results below will most likely be incomplete.
|
||||
There is no installed package depending on "vendor1/package1" in versions not matching ^1.4
|
||||
Not finding what you were looking for? Try calling `composer require "vendor1/package1:^1.4" --dry-run` to get another view on the problem.
|
||||
OUTPUT
|
||||
OUTPUT,
|
||||
0
|
||||
];
|
||||
|
||||
yield 'there is no installed package depending on the package in versions not matching a specific version' => [
|
||||
|
@ -443,7 +450,8 @@ OUTPUT
|
|||
<<<OUTPUT
|
||||
There is no installed package depending on "vendor1/package1" in versions not matching ^1.3
|
||||
Not finding what you were looking for? Try calling `composer require "vendor1/package1:^1.3" --dry-run` to get another view on the problem.
|
||||
OUTPUT
|
||||
OUTPUT,
|
||||
0
|
||||
];
|
||||
|
||||
yield 'an installed package requires an incompatible version of the inspected package' => [
|
||||
|
@ -451,7 +459,8 @@ OUTPUT
|
|||
<<<OUTPUT
|
||||
vendor2/package2 1.0.0 requires vendor2/package3 (1.4.*)
|
||||
Not finding what you were looking for? Try calling `composer update "vendor2/package3:1.5.0" --dry-run` to get another view on the problem.
|
||||
OUTPUT
|
||||
OUTPUT,
|
||||
1
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,6 +210,14 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
|||
return new ApplicationTester($application);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims the entire string but also the trailing spaces off of every line
|
||||
*/
|
||||
protected function trimLines(string $str): string
|
||||
{
|
||||
return trim(Preg::replace('{^(.*?) *$}m', '$1', $str));
|
||||
}
|
||||
|
||||
protected static function getVersionParser(): VersionParser
|
||||
{
|
||||
if (!self::$parser) {
|
||||
|
|
Loading…
Reference in New Issue