2022-02-23 15:58:18 +00:00
|
|
|
<?php declare(strict_types=1);
|
2014-07-15 02:25:44 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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\Package\Version;
|
|
|
|
|
2021-11-11 11:24:12 +00:00
|
|
|
use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
|
2014-07-15 02:25:44 +00:00
|
|
|
use Composer\Package\Version\VersionSelector;
|
2015-10-27 14:43:04 +00:00
|
|
|
use Composer\Package\Package;
|
|
|
|
use Composer\Package\Link;
|
2020-11-26 13:24:16 +00:00
|
|
|
use Composer\Package\AliasPackage;
|
2020-05-04 19:12:21 +00:00
|
|
|
use Composer\Repository\PlatformRepository;
|
2020-11-26 13:24:16 +00:00
|
|
|
use Composer\Package\Version\VersionParser;
|
2020-02-07 03:18:45 +00:00
|
|
|
use Composer\Test\TestCase;
|
2014-07-15 02:25:44 +00:00
|
|
|
|
2017-11-04 14:52:13 +00:00
|
|
|
class VersionSelectorTest extends TestCase
|
2014-07-15 02:25:44 +00:00
|
|
|
{
|
|
|
|
// A) multiple versions, get the latest one
|
2018-09-10 13:23:40 +00:00
|
|
|
// B) targetPackageVersion will pass to repo set
|
2014-07-15 02:25:44 +00:00
|
|
|
// C) No results, throw exception
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testLatestVersionIsReturned(): void
|
2014-07-15 02:25:44 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
2015-10-27 14:43:04 +00:00
|
|
|
$package1 = $this->createPackage('1.2.1');
|
|
|
|
$package2 = $this->createPackage('1.2.2');
|
|
|
|
$package3 = $this->createPackage('1.2.0');
|
2014-07-15 02:25:44 +00:00
|
|
|
$packages = array($package1, $package2, $package3);
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$repositorySet->expects($this->once())
|
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
2014-07-15 02:25:44 +00:00
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$versionSelector = new VersionSelector($repositorySet);
|
2014-07-15 02:25:44 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName);
|
|
|
|
|
|
|
|
// 1.2.2 should be returned because it's the latest of the returned versions
|
2015-10-27 14:43:04 +00:00
|
|
|
$this->assertSame($package2, $best, 'Latest version should be 1.2.2');
|
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testLatestVersionIsReturnedThatMatchesPhpRequirements(): void
|
2015-10-27 14:43:04 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
2020-05-04 19:12:21 +00:00
|
|
|
$platform = new PlatformRepository(array(), array('php' => '5.5.0'));
|
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$versionSelector = new VersionSelector($repositorySet, $platform);
|
|
|
|
|
2015-10-27 14:43:04 +00:00
|
|
|
$parser = new VersionParser;
|
|
|
|
$package1 = $this->createPackage('1.0.0');
|
2020-09-15 08:44:28 +00:00
|
|
|
$package1->setRequires(array('php' => new Link($packageName, 'php', $parser->parseConstraints('>=5.4'), Link::TYPE_REQUIRE, '>=5.4')));
|
2020-05-04 19:12:21 +00:00
|
|
|
$package2 = $this->createPackage('2.0.0');
|
2020-09-15 08:44:28 +00:00
|
|
|
$package2->setRequires(array('php' => new Link($packageName, 'php', $parser->parseConstraints('>=5.6'), Link::TYPE_REQUIRE, '>=5.6')));
|
2015-10-27 14:43:04 +00:00
|
|
|
$packages = array($package1, $package2);
|
|
|
|
|
2020-05-04 19:12:21 +00:00
|
|
|
$repositorySet->expects($this->any())
|
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
|
|
|
$best = $versionSelector->findBestCandidate($packageName);
|
|
|
|
$this->assertSame($package1, $best, 'Latest version supporting php 5.5 should be returned (1.0.0)');
|
2021-11-11 11:24:12 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName, null, 'stable', PlatformRequirementFilterFactory::ignoreAll());
|
2020-05-04 19:12:21 +00:00
|
|
|
$this->assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (2.0.0)');
|
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testLatestVersionIsReturnedThatMatchesExtRequirements(): void
|
2020-05-04 19:12:21 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
|
|
|
$platform = new PlatformRepository(array(), array('ext-zip' => '5.3.0'));
|
2018-09-10 13:23:40 +00:00
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
2020-05-04 19:12:21 +00:00
|
|
|
$versionSelector = new VersionSelector($repositorySet, $platform);
|
|
|
|
|
|
|
|
$parser = new VersionParser;
|
|
|
|
$package1 = $this->createPackage('1.0.0');
|
2020-09-15 08:44:28 +00:00
|
|
|
$package1->setRequires(array('ext-zip' => new Link($packageName, 'ext-zip', $parser->parseConstraints('^5.2'), Link::TYPE_REQUIRE, '^5.2')));
|
2020-05-04 19:12:21 +00:00
|
|
|
$package2 = $this->createPackage('2.0.0');
|
2020-09-15 08:44:28 +00:00
|
|
|
$package2->setRequires(array('ext-zip' => new Link($packageName, 'ext-zip', $parser->parseConstraints('^5.4'), Link::TYPE_REQUIRE, '^5.4')));
|
2020-05-04 19:12:21 +00:00
|
|
|
$packages = array($package1, $package2);
|
|
|
|
|
|
|
|
$repositorySet->expects($this->any())
|
2018-09-10 13:23:40 +00:00
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
2015-10-27 14:43:04 +00:00
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
2020-05-04 19:12:21 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName);
|
|
|
|
$this->assertSame($package1, $best, 'Latest version supporting ext-zip 5.3.0 should be returned (1.0.0)');
|
2021-11-11 11:24:12 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName, null, 'stable', PlatformRequirementFilterFactory::ignoreAll());
|
2021-10-26 15:24:17 +00:00
|
|
|
$this->assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (2.0.0)');
|
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testLatestVersionIsReturnedThatMatchesPlatformExt(): void
|
2021-10-26 15:24:17 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
|
|
|
$platform = new PlatformRepository();
|
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$versionSelector = new VersionSelector($repositorySet, $platform);
|
|
|
|
|
|
|
|
$parser = new VersionParser;
|
|
|
|
$package1 = $this->createPackage('1.0.0');
|
|
|
|
$package2 = $this->createPackage('2.0.0');
|
|
|
|
$package2->setRequires(array('ext-barfoo' => new Link($packageName, 'ext-barfoo', $parser->parseConstraints('*'), Link::TYPE_REQUIRE, '*')));
|
|
|
|
$packages = array($package1, $package2);
|
|
|
|
|
|
|
|
$repositorySet->expects($this->any())
|
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
|
|
|
$best = $versionSelector->findBestCandidate($packageName);
|
|
|
|
$this->assertSame($package1, $best, 'Latest version not requiring ext-barfoo should be returned (1.0.0)');
|
2021-11-11 11:24:12 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName, null, 'stable', PlatformRequirementFilterFactory::ignoreAll());
|
2020-05-04 19:12:21 +00:00
|
|
|
$this->assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (2.0.0)');
|
|
|
|
}
|
2015-10-27 14:43:04 +00:00
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testLatestVersionIsReturnedThatMatchesComposerRequirements(): void
|
2020-05-04 19:12:21 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
|
|
|
$platform = new PlatformRepository(array(), array('composer-runtime-api' => '1.0.0'));
|
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$versionSelector = new VersionSelector($repositorySet, $platform);
|
|
|
|
|
|
|
|
$parser = new VersionParser;
|
|
|
|
$package1 = $this->createPackage('1.0.0');
|
2020-09-15 08:44:28 +00:00
|
|
|
$package1->setRequires(array('composer-runtime-api' => new Link($packageName, 'composer-runtime-api', $parser->parseConstraints('^1.0'), Link::TYPE_REQUIRE, '^1.0')));
|
2020-05-04 19:12:21 +00:00
|
|
|
$package2 = $this->createPackage('1.1.0');
|
2020-09-15 08:44:28 +00:00
|
|
|
$package2->setRequires(array('composer-runtime-api' => new Link($packageName, 'composer-runtime-api', $parser->parseConstraints('^2.0'), Link::TYPE_REQUIRE, '^2.0')));
|
2020-05-04 19:12:21 +00:00
|
|
|
$packages = array($package1, $package2);
|
|
|
|
|
|
|
|
$repositorySet->expects($this->any())
|
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
|
|
|
$best = $versionSelector->findBestCandidate($packageName);
|
|
|
|
$this->assertSame($package1, $best, 'Latest version supporting composer 1 should be returned (1.0.0)');
|
2021-11-11 11:24:12 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName, null, 'stable', PlatformRequirementFilterFactory::ignoreAll());
|
2020-05-04 19:12:21 +00:00
|
|
|
$this->assertSame($package2, $best, 'Latest version should be returned when ignoring platform reqs (1.1.0)');
|
2015-10-27 14:43:04 +00:00
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testMostStableVersionIsReturned(): void
|
2015-10-27 14:43:04 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
|
|
|
$package1 = $this->createPackage('1.0.0');
|
|
|
|
$package2 = $this->createPackage('1.1.0-beta');
|
|
|
|
$packages = array($package1, $package2);
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$repositorySet->expects($this->once())
|
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
2015-10-27 14:43:04 +00:00
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$versionSelector = new VersionSelector($repositorySet);
|
2015-10-27 14:43:04 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName);
|
|
|
|
|
|
|
|
$this->assertSame($package1, $best, 'Latest most stable version should be returned (1.0.0)');
|
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testMostStableVersionIsReturnedRegardlessOfOrder(): void
|
2016-09-27 14:59:48 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
|
|
|
$package1 = $this->createPackage('2.x-dev');
|
|
|
|
$package2 = $this->createPackage('2.0.0-beta3');
|
|
|
|
$packages = array($package1, $package2);
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
2021-12-09 16:09:07 +00:00
|
|
|
$repositorySet->expects($this->exactly(2))
|
2018-09-10 13:23:40 +00:00
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
2021-12-09 16:09:07 +00:00
|
|
|
->willReturnOnConsecutiveCalls(
|
|
|
|
$packages,
|
|
|
|
array_reverse($packages)
|
|
|
|
);
|
2016-09-27 14:59:48 +00:00
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$versionSelector = new VersionSelector($repositorySet);
|
2020-05-04 19:12:21 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName);
|
2016-09-27 14:59:48 +00:00
|
|
|
$this->assertSame($package2, $best, 'Expecting 2.0.0-beta3, cause beta is more stable than dev');
|
|
|
|
|
2020-05-04 19:12:21 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName);
|
2016-09-27 14:59:48 +00:00
|
|
|
$this->assertSame($package2, $best, 'Expecting 2.0.0-beta3, cause beta is more stable than dev');
|
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testHighestVersionIsReturned(): void
|
2015-10-27 14:43:04 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
|
|
|
$package1 = $this->createPackage('1.0.0');
|
|
|
|
$package2 = $this->createPackage('1.1.0-beta');
|
|
|
|
$packages = array($package1, $package2);
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$repositorySet->expects($this->once())
|
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
2015-10-27 14:43:04 +00:00
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$versionSelector = new VersionSelector($repositorySet);
|
2020-05-04 19:12:21 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName, null, 'dev');
|
2015-11-14 15:04:04 +00:00
|
|
|
|
|
|
|
$this->assertSame($package2, $best, 'Latest version should be returned (1.1.0-beta)');
|
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testHighestVersionMatchingStabilityIsReturned(): void
|
2015-11-14 15:04:04 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
|
|
|
$package1 = $this->createPackage('1.0.0');
|
|
|
|
$package2 = $this->createPackage('1.1.0-beta');
|
|
|
|
$package3 = $this->createPackage('1.2.0-alpha');
|
|
|
|
$packages = array($package1, $package2, $package3);
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$repositorySet->expects($this->once())
|
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
2015-11-14 15:04:04 +00:00
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$versionSelector = new VersionSelector($repositorySet);
|
2020-05-04 19:12:21 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName, null, 'beta');
|
2015-10-27 14:43:04 +00:00
|
|
|
|
2016-04-28 21:31:06 +00:00
|
|
|
$this->assertSame($package2, $best, 'Latest version should be returned (1.1.0-beta)');
|
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testMostStableUnstableVersionIsReturned(): void
|
2016-04-28 21:31:06 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
|
|
|
$package2 = $this->createPackage('1.1.0-beta');
|
|
|
|
$package3 = $this->createPackage('1.2.0-alpha');
|
|
|
|
$packages = array($package2, $package3);
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$repositorySet->expects($this->once())
|
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
2016-04-28 21:31:06 +00:00
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$versionSelector = new VersionSelector($repositorySet);
|
2020-05-04 19:12:21 +00:00
|
|
|
$best = $versionSelector->findBestCandidate($packageName, null, 'stable');
|
2016-04-28 21:31:06 +00:00
|
|
|
|
2015-10-27 14:43:04 +00:00
|
|
|
$this->assertSame($package2, $best, 'Latest version should be returned (1.1.0-beta)');
|
2014-07-15 02:25:44 +00:00
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testDefaultBranchAliasIsNeverReturned(): void
|
2020-11-26 13:24:16 +00:00
|
|
|
{
|
|
|
|
$packageName = 'foobar';
|
|
|
|
|
|
|
|
$package = $this->createPackage('1.1.0-beta');
|
|
|
|
$package2 = $this->createPackage('dev-main');
|
|
|
|
$package2Alias = new AliasPackage($package2, VersionParser::DEFAULT_BRANCH_ALIAS, VersionParser::DEFAULT_BRANCH_ALIAS);
|
|
|
|
$packages = array($package, $package2Alias);
|
|
|
|
|
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$repositorySet->expects($this->once())
|
|
|
|
->method('findPackages')
|
|
|
|
->with($packageName, null)
|
|
|
|
->will($this->returnValue($packages));
|
|
|
|
|
|
|
|
$versionSelector = new VersionSelector($repositorySet);
|
|
|
|
$best = $versionSelector->findBestCandidate($packageName, null, 'dev');
|
|
|
|
|
|
|
|
$this->assertSame($package2, $best, 'Latest version should be returned (dev-main)');
|
|
|
|
}
|
|
|
|
|
2022-02-18 09:38:54 +00:00
|
|
|
public function testFalseReturnedOnNoPackages(): void
|
2014-07-15 02:25:44 +00:00
|
|
|
{
|
2018-09-10 13:23:40 +00:00
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$repositorySet->expects($this->once())
|
|
|
|
->method('findPackages')
|
2014-07-15 02:25:44 +00:00
|
|
|
->will($this->returnValue(array()));
|
|
|
|
|
2018-09-10 13:23:40 +00:00
|
|
|
$versionSelector = new VersionSelector($repositorySet);
|
2014-07-15 02:25:44 +00:00
|
|
|
$best = $versionSelector->findBestCandidate('foobaz');
|
|
|
|
$this->assertFalse($best, 'No versions are available returns false');
|
|
|
|
}
|
|
|
|
|
2014-09-12 15:23:20 +00:00
|
|
|
/**
|
2021-11-01 20:44:12 +00:00
|
|
|
* @dataProvider provideRecommendedRequireVersionPackages
|
|
|
|
*
|
|
|
|
* @param string $prettyVersion
|
|
|
|
* @param string $expectedVersion
|
|
|
|
* @param string|null $branchAlias
|
|
|
|
* @param string $packageName
|
2014-09-12 15:23:20 +00:00
|
|
|
*/
|
2022-02-22 15:47:09 +00:00
|
|
|
public function testFindRecommendedRequireVersion(string $prettyVersion, string $expectedVersion, ?string $branchAlias = null, string $packageName = 'foo/bar'): void
|
2014-09-12 15:23:20 +00:00
|
|
|
{
|
2018-09-10 13:23:40 +00:00
|
|
|
$repositorySet = $this->createMockRepositorySet();
|
|
|
|
$versionSelector = new VersionSelector($repositorySet);
|
2014-09-23 14:19:23 +00:00
|
|
|
$versionParser = new VersionParser();
|
2014-09-12 15:23:20 +00:00
|
|
|
|
2021-08-18 13:51:58 +00:00
|
|
|
$package = new Package($packageName, $versionParser->normalize($prettyVersion), $prettyVersion);
|
2014-09-12 15:23:20 +00:00
|
|
|
|
2021-08-18 13:51:58 +00:00
|
|
|
if ($branchAlias) {
|
|
|
|
$package->setExtra(array('branch-alias' => array($prettyVersion => $branchAlias)));
|
|
|
|
}
|
2014-09-23 14:19:23 +00:00
|
|
|
|
2014-09-12 15:23:20 +00:00
|
|
|
$recommended = $versionSelector->findRecommendedRequireVersion($package);
|
|
|
|
|
|
|
|
// assert that the recommended version is what we expect
|
2015-10-27 14:43:04 +00:00
|
|
|
$this->assertSame($expectedVersion, $recommended);
|
2014-09-12 15:23:20 +00:00
|
|
|
}
|
|
|
|
|
2022-02-21 12:42:28 +00:00
|
|
|
public function provideRecommendedRequireVersionPackages(): array
|
2014-09-12 15:23:20 +00:00
|
|
|
{
|
|
|
|
return array(
|
2021-08-18 13:51:58 +00:00
|
|
|
// real version, expected recommendation, [branch-alias], [pkg name]
|
|
|
|
array('1.2.1', '^1.2'),
|
|
|
|
array('1.2', '^1.2'),
|
|
|
|
array('v1.2.1', '^1.2'),
|
|
|
|
array('3.1.2-pl2', '^3.1'),
|
|
|
|
array('3.1.2-patch', '^3.1'),
|
|
|
|
array('2.0-beta.1', '^2.0@beta'),
|
|
|
|
array('3.1.2-alpha5', '^3.1@alpha'),
|
|
|
|
array('3.0-RC2', '^3.0@RC'),
|
|
|
|
array('0.1.0', '^0.1.0'),
|
|
|
|
array('0.1.3', '^0.1.3'),
|
|
|
|
array('0.0.3', '^0.0.3'),
|
|
|
|
array('0.0.3-alpha', '^0.0.3@alpha'),
|
2014-09-23 14:19:23 +00:00
|
|
|
// date-based versions are not touched at all
|
2021-08-18 13:51:58 +00:00
|
|
|
array('v20121020', 'v20121020'),
|
|
|
|
array('v20121020.2', 'v20121020.2'),
|
2014-09-23 14:19:23 +00:00
|
|
|
// dev packages without alias are not touched at all
|
2021-08-18 13:51:58 +00:00
|
|
|
array('dev-master', 'dev-master'),
|
|
|
|
array('3.1.2-dev', '3.1.2-dev'),
|
2014-09-23 14:19:23 +00:00
|
|
|
// dev packages with alias inherit the alias
|
2021-08-18 13:51:58 +00:00
|
|
|
array('dev-master', '^2.1@dev', '2.1.x-dev'),
|
|
|
|
array('dev-master', '^2.1@dev', '2.1-dev'),
|
|
|
|
array('dev-master', '^2.1@dev', '2.1.3.x-dev'),
|
|
|
|
array('dev-master', '^2.0@dev', '2.x-dev'),
|
|
|
|
array('dev-master', '^0.3.0@dev', '0.3.x-dev'),
|
|
|
|
array('dev-master', '^0.0.3@dev', '0.0.3.x-dev'),
|
|
|
|
array('dev-master', 'dev-master', VersionParser::DEFAULT_BRANCH_ALIAS),
|
2014-12-01 05:09:35 +00:00
|
|
|
// numeric alias
|
2021-08-18 13:51:58 +00:00
|
|
|
array('3.x-dev', '^3.0@dev', '3.0.x-dev'),
|
|
|
|
array('3.x-dev', '^3.0@dev', '3.0-dev'),
|
2021-05-17 12:36:46 +00:00
|
|
|
// ext in sync with php
|
2021-08-18 13:51:58 +00:00
|
|
|
array(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION, '*', null, 'ext-filter'),
|
2021-05-17 12:36:46 +00:00
|
|
|
// ext versioned individually
|
2021-08-18 13:51:58 +00:00
|
|
|
array('3.0.5', '^3.0', null, 'ext-xdebug'),
|
2014-09-12 15:23:20 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-01 20:44:12 +00:00
|
|
|
/**
|
|
|
|
* @param string $version
|
|
|
|
*
|
|
|
|
* @return Package
|
|
|
|
*/
|
2022-02-22 15:47:09 +00:00
|
|
|
private function createPackage(string $version): Package
|
2014-07-15 02:25:44 +00:00
|
|
|
{
|
2015-10-27 14:43:04 +00:00
|
|
|
$parser = new VersionParser();
|
2015-11-21 19:28:10 +00:00
|
|
|
|
2015-10-27 14:43:04 +00:00
|
|
|
return new Package('foo', $parser->normalize($version), $version);
|
2014-07-15 02:25:44 +00:00
|
|
|
}
|
|
|
|
|
2021-11-01 20:44:12 +00:00
|
|
|
/**
|
|
|
|
* @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Repository\RepositorySet
|
|
|
|
*/
|
2018-09-10 13:23:40 +00:00
|
|
|
private function createMockRepositorySet()
|
2014-07-15 02:25:44 +00:00
|
|
|
{
|
2018-09-10 13:23:40 +00:00
|
|
|
return $this->getMockBuilder('Composer\Repository\RepositorySet')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
2014-07-15 02:25:44 +00:00
|
|
|
}
|
|
|
|
}
|