2017-09-26 13:06:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
|
|
|
|
use Composer\Package\Version\VersionParser;
|
2020-02-07 03:18:45 +00:00
|
|
|
use Composer\Test\TestCase;
|
2017-09-26 13:06:39 +00:00
|
|
|
|
2017-11-04 14:52:13 +00:00
|
|
|
class VersionParserTest extends TestCase
|
2017-09-26 13:06:39 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider getParseNameVersionPairsData
|
|
|
|
*/
|
|
|
|
public function testParseNameVersionPairs($pairs, $result)
|
|
|
|
{
|
|
|
|
$versionParser = new VersionParser();
|
|
|
|
|
|
|
|
$this->assertSame($result, $versionParser->parseNameVersionPairs($pairs));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getParseNameVersionPairsData()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array(array('php:^7.0'), array(array('name' => 'php', 'version' => '^7.0'))),
|
|
|
|
array(array('php', '^7.0'), array(array('name' => 'php', 'version' => '^7.0'))),
|
|
|
|
array(array('php', 'ext-apcu'), array(array('name' => 'php'), array('name' => 'ext-apcu'))),
|
|
|
|
);
|
|
|
|
}
|
2018-04-13 11:48:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider getIsUpgradeTests
|
|
|
|
*/
|
|
|
|
public function testIsUpgrade($from, $to, $expected)
|
|
|
|
{
|
|
|
|
$this->assertSame($expected, VersionParser::isUpgrade($from, $to));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIsUpgradeTests()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array('0.9.0.0', '1.0.0.0', true),
|
|
|
|
array('1.0.0.0', '0.9.0.0', false),
|
2020-06-25 06:56:14 +00:00
|
|
|
array('1.0.0.0', VersionParser::DEFAULT_BRANCH_ALIAS, true),
|
|
|
|
array(VersionParser::DEFAULT_BRANCH_ALIAS, VersionParser::DEFAULT_BRANCH_ALIAS, true),
|
|
|
|
array(VersionParser::DEFAULT_BRANCH_ALIAS, '1.0.0.0', false),
|
2018-04-13 11:48:30 +00:00
|
|
|
array('1.0.0.0', 'dev-foo', true),
|
|
|
|
array('dev-foo', 'dev-foo', true),
|
|
|
|
array('dev-foo', '1.0.0.0', true),
|
|
|
|
);
|
|
|
|
}
|
2017-09-26 13:06:39 +00:00
|
|
|
}
|