mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Semantic Version Parsing: ~version
Implemented `~` according to #643 and used the following versions as a test case as defined by @Seldaek: * "~1.2.3.4" = ">=1.2.3.4 <1.2.4.0-dev" * "~1.2.3" = ">=1.2.3 <1.3.0-dev" * "~1.2" = ">=1.2.0 <2.0.0-dev" * "~1" = ">=1.0.0 <2.0.0-dev" Refs #643
This commit is contained in:
parent
62bb5b339b
commit
96a76eeffc
2 changed files with 47 additions and 0 deletions
|
@ -240,6 +240,31 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider tildeConstraints
|
||||
*/
|
||||
public function testParseTildeWildcard($input, $min, $max)
|
||||
{
|
||||
$parser = new VersionParser;
|
||||
if ($min) {
|
||||
$expected = new MultiConstraint(array($min, $max));
|
||||
} else {
|
||||
$expected = $max;
|
||||
}
|
||||
|
||||
$this->assertSame((string) $expected, (string) $parser->parseConstraints($input));
|
||||
}
|
||||
|
||||
public function tildeConstraints()
|
||||
{
|
||||
return array(
|
||||
array('~1', new VersionConstraint('>=', '1.0.0.0'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.2', new VersionConstraint('>=', '1.2.0.0'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.2.3', new VersionConstraint('>=', '1.2.3.0'), new VersionConstraint('<', '1.3.0.0-dev')),
|
||||
array('~1.2.3.4', new VersionConstraint('>=', '1.2.3.4'), new VersionConstraint('<', '1.2.4.0-dev')),
|
||||
);
|
||||
}
|
||||
|
||||
public function testParseConstraintsMulti()
|
||||
{
|
||||
$parser = new VersionParser;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue