|
@@ -88,6 +88,33 @@ class VersionSelectorTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->assertSame($package1, $best, 'Latest most stable version should be returned (1.0.0)');
|
|
|
}
|
|
|
|
|
|
+ public function testMostStableVersionIsReturnedRegardlessOfOrder()
|
|
|
+ {
|
|
|
+ $packageName = 'foobar';
|
|
|
+
|
|
|
+ $package1 = $this->createPackage('2.x-dev');
|
|
|
+ $package2 = $this->createPackage('2.0.0-beta3');
|
|
|
+ $packages = array($package1, $package2);
|
|
|
+
|
|
|
+ $pool = $this->createMockPool();
|
|
|
+ $pool->expects($this->at(0))
|
|
|
+ ->method('whatProvides')
|
|
|
+ ->with($packageName, null, true)
|
|
|
+ ->will($this->returnValue($packages));
|
|
|
+
|
|
|
+ $pool->expects($this->at(1))
|
|
|
+ ->method('whatProvides')
|
|
|
+ ->with($packageName, null, true)
|
|
|
+ ->will($this->returnValue(array_reverse($packages)));
|
|
|
+
|
|
|
+ $versionSelector = new VersionSelector($pool);
|
|
|
+ $best = $versionSelector->findBestCandidate($packageName, null, null);
|
|
|
+ $this->assertSame($package2, $best, 'Expecting 2.0.0-beta3, cause beta is more stable than dev');
|
|
|
+
|
|
|
+ $best = $versionSelector->findBestCandidate($packageName, null, null);
|
|
|
+ $this->assertSame($package2, $best, 'Expecting 2.0.0-beta3, cause beta is more stable than dev');
|
|
|
+ }
|
|
|
+
|
|
|
public function testHighestVersionIsReturned()
|
|
|
{
|
|
|
$packageName = 'foobar';
|