1
0
Fork 0

Prevent seeing dev versions as equal when they are not, fixes #848

pull/899/head
Jordi Boggiano 2012-07-11 20:25:22 +02:00
parent 37ef2037cf
commit 2f7130200a
3 changed files with 8 additions and 1 deletions

View File

@ -49,7 +49,7 @@ class DefaultPolicy implements PolicyInterface
public function selectPreferedPackages(Pool $pool, array $installedMap, array $literals)
{
$packages = $this->groupLiteralsByNamePreferInstalled($pool,$installedMap, $literals);
$packages = $this->groupLiteralsByNamePreferInstalled($pool, $installedMap, $literals);
foreach ($packages as &$literals) {
$policy = $this;

View File

@ -58,6 +58,11 @@ class VersionConstraint extends SpecificConstraint
$isProviderEqualOp = '==' === $provider->operator;
$isProviderNonEqualOp = '!=' === $provider->operator;
// dev- versions can not be compared with version_compare
if ('dev-' === substr($provider->version, 0, 4) && 'dev-' === substr($this->version, 0, 4)) {
return $isEqualOp && $isProviderEqualOp && $provider->version === $this->version ? true : false;
}
// '!=' operator is match when other operator is not '==' operator or version is not match
// these kinds of comparisons always have a solution
if ($isNonEqualOp || $isProviderNonEqualOp) {

View File

@ -33,6 +33,7 @@ class VersionConstraintTest extends \PHPUnit_Framework_TestCase
array('!=', '1', '<=', '1'),
array('!=', '1', '>', '1'),
array('!=', '1', '>=', '1'),
array('==', 'dev-foo-bar', '==', 'dev-foo-bar'),
);
}
@ -61,6 +62,7 @@ class VersionConstraintTest extends \PHPUnit_Framework_TestCase
array('==', '2', '<', '2'),
array('!=', '1', '==', '1'),
array('==', '1', '!=', '1'),
array('==', 'dev-foo-dist', '==', 'dev-foo-zist'),
);
}