mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
[Tests] Use static data providers (#11197)
This commit is contained in:
parent
0cf57255d4
commit
8ff237afb6
86 changed files with 715 additions and 723 deletions
|
@ -46,14 +46,20 @@ class BasePackageTest extends TestCase
|
|||
/**
|
||||
* @dataProvider provideFormattedVersions
|
||||
*/
|
||||
public function testFormatVersionForDevPackage(BasePackage $package, bool $truncate, string $expected): void
|
||||
public function testFormatVersionForDevPackage(string $sourceReference, bool $truncate, string $expected): void
|
||||
{
|
||||
$package = $this->getMockForAbstractClass('\Composer\Package\BasePackage', [], '', false);
|
||||
$package->expects($this->once())->method('isDev')->will($this->returnValue(true));
|
||||
$package->expects($this->any())->method('getSourceType')->will($this->returnValue('git'));
|
||||
$package->expects($this->once())->method('getPrettyVersion')->will($this->returnValue('PrettyVersion'));
|
||||
$package->expects($this->any())->method('getSourceReference')->will($this->returnValue($sourceReference));
|
||||
|
||||
$this->assertSame($expected, $package->getFullPrettyVersion($truncate));
|
||||
}
|
||||
|
||||
public function provideFormattedVersions(): array
|
||||
public static function provideFormattedVersions(): array
|
||||
{
|
||||
$data = [
|
||||
return [
|
||||
[
|
||||
'sourceReference' => 'v2.1.0-RC2',
|
||||
'truncate' => true,
|
||||
|
@ -75,18 +81,6 @@ class BasePackageTest extends TestCase
|
|||
'expected' => 'PrettyVersion bbf527a27356414bfa9bf520f018c5cb7af67c77',
|
||||
],
|
||||
];
|
||||
|
||||
$createPackage = function ($arr): array {
|
||||
$package = $this->getMockForAbstractClass('\Composer\Package\BasePackage', [], '', false);
|
||||
$package->expects($this->once())->method('isDev')->will($this->returnValue(true));
|
||||
$package->expects($this->any())->method('getSourceType')->will($this->returnValue('git'));
|
||||
$package->expects($this->once())->method('getPrettyVersion')->will($this->returnValue('PrettyVersion'));
|
||||
$package->expects($this->any())->method('getSourceReference')->will($this->returnValue($arr['sourceReference']));
|
||||
|
||||
return [$package, $arr['truncate'], $arr['expected']];
|
||||
};
|
||||
|
||||
return array_map($createPackage, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,7 +99,7 @@ class BasePackageTest extends TestCase
|
|||
/**
|
||||
* @return mixed[][]
|
||||
*/
|
||||
public function dataPackageNamesToRegexp(): array
|
||||
public static function dataPackageNamesToRegexp(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue