1
0
Fork 0

Tests for MultiConstraints on versions

pull/1/head
Nils Adermann 2011-04-18 22:54:08 +02:00
parent f0af6b7d57
commit ec94b76c7c
1 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,54 @@
<?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;
use Composer\Package\LinkConstraint\VersionConstraint;
use Composer\Package\LinkConstraint\MultiConstraint;
class MultiConstraintTest extends \PHPUnit_Framework_TestCase
{
public function testMultiVersionMatchSucceeds()
{
$versionRequireStart = new VersionConstraint('>', '1.0');
$versionRequireEnd = new VersionConstraint('<', '1.2');
$versionProvide = new VersionConstraint('==', '1.1');
$multiRequire = new MultiConstraint(array($versionRequireStart, $versionRequireEnd));
$this->assertTrue($multiRequire->matches($versionProvide));
}
public function testMultiVersionProvidedMatchSucceeds()
{
$versionRequireStart = new VersionConstraint('>', '1.0');
$versionRequireEnd = new VersionConstraint('<', '1.2');
$versionProvideStart = new VersionConstraint('>=', '1.1');
$versionProvideEnd = new VersionConstraint('<', '2.0');
$multiRequire = new MultiConstraint(array($versionRequireStart, $versionRequireEnd));
$multiProvide = new MultiConstraint(array($versionProvideStart, $versionProvideEnd));
$this->assertTrue($multiRequire->matches($multiProvide));
}
public function testMultiVersionMatchFails()
{
$versionRequireStart = new VersionConstraint('>', '1.0');
$versionRequireEnd = new VersionConstraint('<', '1.2');
$versionProvide = new VersionConstraint('==', '1.2');
$multiRequire = new MultiConstraint(array($versionRequireStart, $versionRequireEnd));
$this->assertFalse($multiRequire->matches($versionProvide));
}
}