2011-04-05 15:37:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2011-04-16 12:42:35 +00:00
|
|
|
* This file is part of Composer.
|
2011-04-05 15:37:19 +00:00
|
|
|
*
|
2011-04-16 12:42:35 +00:00
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
2011-04-05 15:37:19 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Composer\Test\DependencyResolver;
|
|
|
|
|
|
|
|
use Composer\DependencyResolver\Literal;
|
2011-11-20 14:06:12 +00:00
|
|
|
use Composer\Test\TestCase;
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2011-11-20 14:06:12 +00:00
|
|
|
class LiteralTest extends TestCase
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
2011-08-21 03:15:12 +00:00
|
|
|
protected $package;
|
|
|
|
|
|
|
|
public function setUp()
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
2011-11-20 14:06:12 +00:00
|
|
|
$this->package = $this->getPackage('foo', '1');
|
2011-08-21 03:15:12 +00:00
|
|
|
$this->package->setId(12);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLiteralWanted()
|
|
|
|
{
|
|
|
|
$literal = new Literal($this->package, true);
|
|
|
|
|
|
|
|
$this->assertEquals(12, $literal->getId());
|
|
|
|
$this->assertEquals('+'.(string) $this->package, (string) $literal);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLiteralUnwanted()
|
|
|
|
{
|
|
|
|
$literal = new Literal($this->package, false);
|
|
|
|
|
|
|
|
$this->assertEquals(-12, $literal->getId());
|
|
|
|
$this->assertEquals('-'.(string) $this->package, (string) $literal);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLiteralInverted()
|
|
|
|
{
|
|
|
|
$literal = new Literal($this->package, false);
|
|
|
|
|
|
|
|
$inverted = $literal->inverted();
|
|
|
|
|
|
|
|
$this->assertInstanceOf('\Composer\DependencyResolver\Literal', $inverted);
|
|
|
|
$this->assertTrue($inverted->isWanted());
|
|
|
|
$this->assertSame($this->package, $inverted->getPackage());
|
|
|
|
$this->assertFalse($literal->equals($inverted));
|
|
|
|
|
|
|
|
$doubleInverted = $inverted->inverted();
|
|
|
|
|
|
|
|
$this->assertInstanceOf('\Composer\DependencyResolver\Literal', $doubleInverted);
|
|
|
|
$this->assertFalse($doubleInverted->isWanted());
|
|
|
|
$this->assertSame($this->package, $doubleInverted->getPackage());
|
|
|
|
|
|
|
|
$this->assertTrue($literal->equals($doubleInverted));
|
2011-04-05 15:37:19 +00:00
|
|
|
}
|
|
|
|
}
|