From db18e1b5607ec46005b29629726ca0a718ceab87 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 20 Aug 2011 23:15:12 -0400 Subject: [PATCH] Add a few proper tests for literals, all tests passing now --- .../Test/DependencyResolver/LiteralTest.php | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/tests/Composer/Test/DependencyResolver/LiteralTest.php b/tests/Composer/Test/DependencyResolver/LiteralTest.php index fac57d893..464272099 100644 --- a/tests/Composer/Test/DependencyResolver/LiteralTest.php +++ b/tests/Composer/Test/DependencyResolver/LiteralTest.php @@ -17,9 +17,47 @@ use Composer\Package\MemoryPackage; class LiteralTest extends \PHPUnit_Framework_TestCase { - public function testLiteral() + protected $package; + + public function setUp() { - $literal = new Literal(new MemoryPackage('foo', '1'), true); - $this->markTestIncomplete('Eh?'); + $this->package = new MemoryPackage('foo', '1'); + $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)); } }