1
0
Fork 0

Merge pull request #9214 from mitelg/add-pretty-constraint

Add pretty constraint
pull/9241/head
Jordi Boggiano 2020-09-21 14:46:17 +02:00 committed by GitHub
commit 5df1797d20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 161 additions and 127 deletions

View File

@ -17,6 +17,7 @@ use Composer\DependencyResolver\DefaultPolicy;
use Composer\Json\JsonFile; use Composer\Json\JsonFile;
use Composer\Package\BasePackage; use Composer\Package\BasePackage;
use Composer\Package\CompletePackageInterface; use Composer\Package\CompletePackageInterface;
use Composer\Package\Link;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser; use Composer\Package\Version\VersionParser;
use Composer\Package\Version\VersionSelector; use Composer\Package\Version\VersionSelector;
@ -613,8 +614,8 @@ EOT
$io = $this->getIO(); $io = $this->getIO();
$this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null); $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
$this->printLinks($package, 'requires'); $this->printLinks($package, Link::TYPE_REQUIRE);
$this->printLinks($package, 'devRequires', 'requires (dev)'); $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
if ($package->getSuggests()) { if ($package->getSuggests()) {
$io->write("\n<info>suggests</info>"); $io->write("\n<info>suggests</info>");
@ -623,9 +624,9 @@ EOT
} }
} }
$this->printLinks($package, 'provides'); $this->printLinks($package, Link::TYPE_PROVIDE);
$this->printLinks($package, 'conflicts'); $this->printLinks($package, Link::TYPE_CONFLICT);
$this->printLinks($package, 'replaces'); $this->printLinks($package, Link::TYPE_REPLACE);
} }
/** /**
@ -911,7 +912,7 @@ EOT
private function appendLinks($json, CompletePackageInterface $package) private function appendLinks($json, CompletePackageInterface $package)
{ {
foreach (array('requires', 'devRequires', 'provides', 'conflicts', 'replaces') as $linkType) { foreach (Link::$TYPES as $linkType) {
$json = $this->appendLink($json, $package, $linkType); $json = $this->appendLink($json, $package, $linkType);
} }

View File

@ -57,7 +57,7 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
$this->stability = VersionParser::parseStability($version); $this->stability = VersionParser::parseStability($version);
$this->dev = $this->stability === 'dev'; $this->dev = $this->stability === 'dev';
foreach (array('requires', 'devRequires', 'conflicts', 'provides', 'replaces') as $type) { foreach (Link::$TYPES as $type) {
$links = $aliasOf->{'get' . ucfirst($type)}(); $links = $aliasOf->{'get' . ucfirst($type)}();
$this->$type = $this->replaceSelfVersionDependencies($links, $type); $this->$type = $this->replaceSelfVersionDependencies($links, $type);
} }
@ -180,7 +180,7 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
$prettyVersion = $this->aliasOf->getPrettyVersion(); $prettyVersion = $this->aliasOf->getPrettyVersion();
} }
if (\in_array($linkType, array('conflicts', 'provides', 'replaces'), true)) { if (\in_array($linkType, array(Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE), true)) {
$newLinks = array(); $newLinks = array();
foreach ($links as $link) { foreach ($links as $link) {
// link is self.version, but must be replacing also the replaced version // link is self.version, but must be replacing also the replaced version
@ -193,7 +193,7 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
} else { } else {
foreach ($links as $index => $link) { foreach ($links as $index => $link) {
if ('self.version' === $link->getPrettyConstraint()) { if ('self.version' === $link->getPrettyConstraint()) {
if ($linkType === 'requires') { if ($linkType === Link::TYPE_REQUIRE) {
$this->hasSelfVersionRequires = true; $this->hasSelfVersionRequires = true;
} }
$links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion); $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);

View File

@ -22,12 +22,15 @@ use Composer\Repository\PlatformRepository;
*/ */
abstract class BasePackage implements PackageInterface abstract class BasePackage implements PackageInterface
{ {
/**
* @phpstan-var array<string, array{description: string, method: Link::TYPE_*}>
*/
public static $supportedLinkTypes = array( public static $supportedLinkTypes = array(
'require' => array('description' => 'requires', 'method' => 'requires'), 'require' => array('description' => 'requires', 'method' => Link::TYPE_REQUIRE),
'conflict' => array('description' => 'conflicts', 'method' => 'conflicts'), 'conflict' => array('description' => 'conflicts', 'method' => Link::TYPE_CONFLICT),
'provide' => array('description' => 'provides', 'method' => 'provides'), 'provide' => array('description' => 'provides', 'method' => Link::TYPE_PROVIDE),
'replace' => array('description' => 'replaces', 'method' => 'replaces'), 'replace' => array('description' => 'replaces', 'method' => Link::TYPE_REPLACE),
'require-dev' => array('description' => 'requires (for development)', 'method' => 'devRequires'), 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
); );
const STABILITY_STABLE = 0; const STABILITY_STABLE = 0;

View File

@ -21,6 +21,26 @@ use Composer\Semver\Constraint\ConstraintInterface;
*/ */
class Link class Link
{ {
const TYPE_REQUIRE = 'requires';
const TYPE_DEV_REQUIRE = 'devRequires';
const TYPE_PROVIDE = 'provides';
const TYPE_CONFLICT = 'conflicts';
const TYPE_REPLACE = 'replaces';
/**
* Will be converted into a constant once the min PHP version allows this
*
* @private
* @var string[]
*/
public static $TYPES = array(
self::TYPE_REQUIRE,
self::TYPE_DEV_REQUIRE,
self::TYPE_PROVIDE,
self::TYPE_CONFLICT,
self::TYPE_REPLACE,
);
/** /**
* @var string * @var string
*/ */
@ -38,6 +58,7 @@ class Link
/** /**
* @var string * @var string
* @phpstan-var self::TYPE_* $description
*/ */
protected $description; protected $description;
@ -49,14 +70,20 @@ class Link
/** /**
* Creates a new package link. * Creates a new package link.
* *
* @param string $source * @param string $source
* @param string $target * @param string $target
* @param ConstraintInterface $constraint Constraint applying to the target of this link * @param ConstraintInterface $constraint Constraint applying to the target of this link
* @param string $description Used to create a descriptive string representation * @param string $description Used to create a descriptive string representation
* @param string|null $prettyConstraint * @phpstan-param self::TYPE_* $description
* @param string|null $prettyConstraint
*/ */
public function __construct($source, $target, ConstraintInterface $constraint, $description = 'relates to', $prettyConstraint = null) public function __construct(
{ $source,
$target,
ConstraintInterface $constraint,
$description = 'relates to',
$prettyConstraint = null
) {
$this->source = strtolower($source); $this->source = strtolower($source);
$this->target = strtolower($target); $this->target = strtolower($target);
$this->constraint = $constraint; $this->constraint = $constraint;

View File

@ -296,10 +296,11 @@ class ArrayLoader implements LoaderInterface
} }
/** /**
* @param string $source source package name * @param string $source source package name
* @param string $sourceVersion source package version (pretty version ideally) * @param string $sourceVersion source package version (pretty version ideally)
* @param string $description link description (e.g. requires, replaces, ..) * @param string $description link description (e.g. requires, replaces, ..)
* @param array $links array of package name => constraint mappings * @phpstan-param Link::TYPE_* $description
* @param array $links array of package name => constraint mappings
* @return Link[] * @return Link[]
*/ */
public function parseLinks($source, $sourceVersion, $description, $links) public function parseLinks($source, $sourceVersion, $description, $links)

View File

@ -213,7 +213,7 @@ class Locker
$requirements = $this->loader->parseLinks( $requirements = $this->loader->parseLinks(
'__root__', '__root__',
'1.0.0', '1.0.0',
'requires', Link::TYPE_REQUIRE,
isset($lockData['platform']) ? $lockData['platform'] : array() isset($lockData['platform']) ? $lockData['platform'] : array()
); );
} }
@ -222,7 +222,7 @@ class Locker
$devRequirements = $this->loader->parseLinks( $devRequirements = $this->loader->parseLinks(
'__root__', '__root__',
'1.0.0', '1.0.0',
'requires', Link::TYPE_REQUIRE,
isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array() isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
); );

View File

@ -75,7 +75,7 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface
*/ */
public function setRequires(array $require) public function setRequires(array $require)
{ {
$this->requires = $this->replaceSelfVersionDependencies($require, 'requires'); $this->requires = $this->replaceSelfVersionDependencies($require, Link::TYPE_REQUIRE);
$this->aliasOf->setRequires($require); $this->aliasOf->setRequires($require);
} }
@ -85,7 +85,7 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface
*/ */
public function setDevRequires(array $devRequire) public function setDevRequires(array $devRequire)
{ {
$this->devRequires = $this->replaceSelfVersionDependencies($devRequire, 'devRequires'); $this->devRequires = $this->replaceSelfVersionDependencies($devRequire, Link::TYPE_DEV_REQUIRE);
$this->aliasOf->setDevRequires($devRequire); $this->aliasOf->setDevRequires($devRequire);
} }
@ -95,7 +95,7 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface
*/ */
public function setConflicts(array $conflicts) public function setConflicts(array $conflicts)
{ {
$this->conflicts = $this->replaceSelfVersionDependencies($conflicts, 'conflicts'); $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
$this->aliasOf->setConflicts($conflicts); $this->aliasOf->setConflicts($conflicts);
} }
@ -104,7 +104,7 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface
*/ */
public function setProvides(array $provides) public function setProvides(array $provides)
{ {
$this->provides = $this->replaceSelfVersionDependencies($provides, 'provides'); $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
$this->aliasOf->setProvides($provides); $this->aliasOf->setProvides($provides);
} }
@ -113,7 +113,7 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface
*/ */
public function setReplaces(array $replaces) public function setReplaces(array $replaces)
{ {
$this->replaces = $this->replaceSelfVersionDependencies($replaces, 'replaces'); $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
$this->aliasOf->setReplaces($replaces); $this->aliasOf->setReplaces($replaces);
} }

View File

@ -176,7 +176,7 @@ class InstalledRepository extends CompositeRepository
$platformPkg = $this->findPackage($link->getTarget(), '*'); $platformPkg = $this->findPackage($link->getTarget(), '*');
$description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing'; $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
$results[] = array($package, new Link($package->getName(), $link->getTarget(), null, 'requires', $link->getPrettyConstraint().' '.$description), false); $results[] = array($package, new Link($package->getName(), $link->getTarget(), null, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false);
continue; continue;
} }

View File

@ -548,7 +548,9 @@ class PlatformRepository extends ArrayRepository
$ext->setDescription('The '.$name.' PHP extension'.$extraDescription); $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
if ($name === 'uuid') { if ($name === 'uuid') {
$ext->setReplaces(array(new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version)))); $ext->setReplaces(array(
new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion())
));
} }
$this->addPackage($ext); $this->addPackage($ext);
@ -585,8 +587,8 @@ class PlatformRepository extends ArrayRepository
$lib = new CompletePackage('lib-'.$name, $version, $prettyVersion); $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
$lib->setDescription($description); $lib->setDescription($description);
$links = function ($alias) use ($name, $version) { $links = function ($alias) use ($name, $version, $lib) {
return new Link('lib-'.$name, 'lib-'.$alias, new Constraint('=', $version)); return new Link('lib-'.$name, 'lib-'.$alias, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
}; };
$lib->setReplaces(array_map($links, $replaces)); $lib->setReplaces(array_map($links, $replaces));
$lib->setProvides(array_map($links, $provides)); $lib->setProvides(array_map($links, $provides));

View File

@ -438,7 +438,7 @@ class AutoloadGeneratorTest extends TestCase
$b->setAutoload(array('psr-4' => array('B\\' => 'src/'))); $b->setAutoload(array('psr-4' => array('B\\' => 'src/')));
$b->setReplaces( $b->setReplaces(
array(new Link('b/b', 'b/c', new Constraint('==', '1.0'), 'replaces')) array(new Link('b/b', 'b/c', new Constraint('==', '1.0'), Link::TYPE_REPLACE))
); );
$this->repository->expects($this->once()) $this->repository->expects($this->once())

View File

@ -192,8 +192,8 @@ class DefaultPolicyTest extends TestCase
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repo->addPackage($packageB = $this->getPackage('B', '2.0')); $this->repo->addPackage($packageB = $this->getPackage('B', '2.0'));
$packageA->setProvides(array(new Link('A', 'X', new Constraint('==', '1.0'), 'provides'))); $packageA->setProvides(array(new Link('A', 'X', new Constraint('==', '1.0'), Link::TYPE_PROVIDE)));
$packageB->setProvides(array(new Link('B', 'X', new Constraint('==', '1.0'), 'provides'))); $packageB->setProvides(array(new Link('B', 'X', new Constraint('==', '1.0'), Link::TYPE_PROVIDE)));
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
@ -212,7 +212,7 @@ class DefaultPolicyTest extends TestCase
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repo->addPackage($packageB = $this->getPackage('B', '2.0')); $this->repo->addPackage($packageB = $this->getPackage('B', '2.0'));
$packageB->setReplaces(array(new Link('B', 'A', new Constraint('==', '1.0'), 'replaces'))); $packageB->setReplaces(array(new Link('B', 'A', new Constraint('==', '1.0'), Link::TYPE_REPLACE)));
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);
@ -232,8 +232,8 @@ class DefaultPolicyTest extends TestCase
$this->repo->addPackage($packageB = $this->getPackage('vendor-b/replacer', '1.0')); $this->repo->addPackage($packageB = $this->getPackage('vendor-b/replacer', '1.0'));
$this->repo->addPackage($packageA = $this->getPackage('vendor-a/replacer', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('vendor-a/replacer', '1.0'));
$packageA->setReplaces(array(new Link('vendor-a/replacer', 'vendor-a/package', new Constraint('==', '1.0'), 'replaces'))); $packageA->setReplaces(array(new Link('vendor-a/replacer', 'vendor-a/package', new Constraint('==', '1.0'), Link::TYPE_REPLACE)));
$packageB->setReplaces(array(new Link('vendor-b/replacer', 'vendor-a/package', new Constraint('==', '1.0'), 'replaces'))); $packageB->setReplaces(array(new Link('vendor-b/replacer', 'vendor-a/package', new Constraint('==', '1.0'), Link::TYPE_REPLACE)));
$this->repositorySet->addRepository($this->repo); $this->repositorySet->addRepository($this->repo);

View File

@ -112,7 +112,7 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0')); $this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1')); $this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('<', '1.1'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('<', '1.1'), Link::TYPE_REQUIRE)));
$this->reposComplete(); $this->reposComplete();
@ -137,7 +137,7 @@ class SolverTest extends TestCase
$this->getVersionConstraint('<=', '1.3'), $this->getVersionConstraint('<=', '1.3'),
$this->getVersionConstraint('<>', '1.3'), $this->getVersionConstraint('<>', '1.3'),
$this->getVersionConstraint('!=', '1.2'), $this->getVersionConstraint('!=', '1.2'),
)), 'requires'), )), Link::TYPE_REQUIRE),
)); ));
$this->reposComplete(); $this->reposComplete();
@ -157,11 +157,11 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageC = $this->getPackage('C', '1.0')); $this->repo->addPackage($packageC = $this->getPackage('C', '1.0'));
$packageB->setRequires(array( $packageB->setRequires(array(
'a' => new Link('B', 'A', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'a' => new Link('B', 'A', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
'c' => new Link('B', 'C', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'c' => new Link('B', 'C', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageC->setRequires(array( $packageC->setRequires(array(
'a' => new Link('C', 'A', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'a' => new Link('C', 'A', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
)); ));
$this->reposComplete(); $this->reposComplete();
@ -205,7 +205,7 @@ class SolverTest extends TestCase
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1')); $this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
$this->reposComplete(); $this->reposComplete();
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0.0.0'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0.0.0'), Link::TYPE_REQUIRE)));
$this->request->fixPackage($packageA); $this->request->fixPackage($packageA);
$this->request->requireName('B', $this->getVersionConstraint('=', '1.1.0.0')); $this->request->requireName('B', $this->getVersionConstraint('=', '1.1.0.0'));
@ -235,8 +235,8 @@ class SolverTest extends TestCase
$this->repo->addPackage($newPackageA = $this->getPackage('A', '1.1')); $this->repo->addPackage($newPackageA = $this->getPackage('A', '1.1'));
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1')); $this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
$packageA->setRequires(array('b' => new Link('A', 'B', new MatchAllConstraint(), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', new MatchAllConstraint(), Link::TYPE_REQUIRE)));
$newPackageA->setRequires(array('b' => new Link('A', 'B', new MatchAllConstraint(), 'requires'))); $newPackageA->setRequires(array('b' => new Link('A', 'B', new MatchAllConstraint(), Link::TYPE_REQUIRE)));
$this->reposComplete(); $this->reposComplete();
@ -341,7 +341,7 @@ class SolverTest extends TestCase
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1')); $this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
$this->repo->addPackage($packageC = $this->getPackage('C', '1.1')); $this->repo->addPackage($packageC = $this->getPackage('C', '1.1'));
$this->repo->addPackage($this->getPackage('D', '1.0')); $this->repo->addPackage($this->getPackage('D', '1.0'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('<', '1.1'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('<', '1.1'), Link::TYPE_REQUIRE)));
$this->reposComplete(); $this->reposComplete();
@ -362,8 +362,8 @@ class SolverTest extends TestCase
$this->repo->addPackage($middlePackageB = $this->getPackage('B', '1.0')); $this->repo->addPackage($middlePackageB = $this->getPackage('B', '1.0'));
$this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1')); $this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1'));
$this->repo->addPackage($oldPackageB = $this->getPackage('B', '0.9')); $this->repo->addPackage($oldPackageB = $this->getPackage('B', '0.9'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('<', '1.1'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('<', '1.1'), Link::TYPE_REQUIRE)));
$packageA->setConflicts(array('b' => new Link('A', 'B', $this->getVersionConstraint('<', '1.0'), 'conflicts'))); $packageA->setConflicts(array('b' => new Link('A', 'B', $this->getVersionConstraint('<', '1.0'), Link::TYPE_CONFLICT)));
$this->reposComplete(); $this->reposComplete();
@ -409,8 +409,8 @@ class SolverTest extends TestCase
{ {
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0')); $this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE)));
$packageQ->setProvides(array('b' => new Link('Q', 'B', $this->getVersionConstraint('=', '1.0'), 'provides'))); $packageQ->setProvides(array('b' => new Link('Q', 'B', $this->getVersionConstraint('=', '1.0'), Link::TYPE_PROVIDE)));
$this->reposComplete(); $this->reposComplete();
@ -427,8 +427,8 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0')); $this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0'));
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0')); $this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE)));
$packageQ->setReplaces(array('b' => new Link('Q', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces'))); $packageQ->setReplaces(array('b' => new Link('Q', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REPLACE)));
$this->reposComplete(); $this->reposComplete();
@ -444,8 +444,8 @@ class SolverTest extends TestCase
{ {
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0')); $this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE)));
$packageQ->setReplaces(array('b' => new Link('Q', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces'))); $packageQ->setReplaces(array('b' => new Link('Q', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REPLACE)));
$this->reposComplete(); $this->reposComplete();
@ -461,8 +461,8 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0')); $this->repo->addPackage($packageQ = $this->getPackage('Q', '1.0'));
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0')); $this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE)));
$packageQ->setReplaces(array('b' => new Link('Q', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces'))); $packageQ->setReplaces(array('b' => new Link('Q', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REPLACE)));
$this->reposComplete(); $this->reposComplete();
@ -479,27 +479,27 @@ class SolverTest extends TestCase
{ {
$this->repo->addPackage($packageX = $this->getPackage('X', '1.0')); $this->repo->addPackage($packageX = $this->getPackage('X', '1.0'));
$packageX->setRequires(array( $packageX->setRequires(array(
'a' => new Link('X', 'A', $this->getVersionConstraint('>=', '2.0.0.0'), 'requires'), 'a' => new Link('X', 'A', $this->getVersionConstraint('>=', '2.0.0.0'), Link::TYPE_REQUIRE),
'b' => new Link('X', 'B', $this->getVersionConstraint('>=', '2.0.0.0'), 'requires'), 'b' => new Link('X', 'B', $this->getVersionConstraint('>=', '2.0.0.0'), Link::TYPE_REQUIRE),
)); ));
$this->repo->addPackage($packageA = $this->getPackage('A', '2.0.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '2.0.0'));
$this->repo->addPackage($newPackageA = $this->getPackage('A', '2.1.0')); $this->repo->addPackage($newPackageA = $this->getPackage('A', '2.1.0'));
$this->repo->addPackage($newPackageB = $this->getPackage('B', '2.1.0')); $this->repo->addPackage($newPackageB = $this->getPackage('B', '2.1.0'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '2.0.0.0'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '2.0.0.0'), Link::TYPE_REQUIRE)));
// new package A depends on version of package B that does not exist // new package A depends on version of package B that does not exist
// => new package A is not installable // => new package A is not installable
$newPackageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '2.2.0.0'), 'requires'))); $newPackageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '2.2.0.0'), Link::TYPE_REQUIRE)));
// add a package S replacing both A and B, so that S and B or S and A cannot be simultaneously installed // add a package S replacing both A and B, so that S and B or S and A cannot be simultaneously installed
// but an alternative option for A and B both exists // but an alternative option for A and B both exists
// this creates a more difficult so solve conflict // this creates a more difficult so solve conflict
$this->repo->addPackage($packageS = $this->getPackage('S', '2.0.0')); $this->repo->addPackage($packageS = $this->getPackage('S', '2.0.0'));
$packageS->setReplaces(array( $packageS->setReplaces(array(
'a' => new Link('S', 'A', $this->getVersionConstraint('>=', '2.0.0.0'), 'replaces'), 'a' => new Link('S', 'A', $this->getVersionConstraint('>=', '2.0.0.0'), Link::TYPE_REPLACE),
'b' => new Link('S', 'B', $this->getVersionConstraint('>=', '2.0.0.0'), 'replaces'), 'b' => new Link('S', 'B', $this->getVersionConstraint('>=', '2.0.0.0'), Link::TYPE_REPLACE),
)); ));
$this->reposComplete(); $this->reposComplete();
@ -518,8 +518,8 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repo->addPackage($packageB1 = $this->getPackage('B', '0.9')); $this->repo->addPackage($packageB1 = $this->getPackage('B', '0.9'));
$this->repo->addPackage($packageB2 = $this->getPackage('B', '1.1')); $this->repo->addPackage($packageB2 = $this->getPackage('B', '1.1'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE)));
$packageB2->setRequires(array('a' => new Link('B', 'A', $this->getVersionConstraint('>=', '1.0'), 'requires'))); $packageB2->setRequires(array('a' => new Link('B', 'A', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE)));
$this->reposComplete(); $this->reposComplete();
@ -537,13 +537,13 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0')); $this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
$this->repo->addPackage($packageC = $this->getPackage('C', '1.0')); $this->repo->addPackage($packageC = $this->getPackage('C', '1.0'));
$this->repo->addPackage($packageD = $this->getPackage('D', '1.0')); $this->repo->addPackage($packageD = $this->getPackage('D', '1.0'));
$packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'))); $packageA->setRequires(array('b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE)));
$packageB->setRequires(array('virtual' => new Link('B', 'Virtual', $this->getVersionConstraint('>=', '1.0'), 'requires'))); $packageB->setRequires(array('virtual' => new Link('B', 'Virtual', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE)));
$packageC->setProvides(array('virtual' => new Link('C', 'Virtual', $this->getVersionConstraint('==', '1.0'), 'provides'))); $packageC->setProvides(array('virtual' => new Link('C', 'Virtual', $this->getVersionConstraint('==', '1.0'), Link::TYPE_PROVIDE)));
$packageD->setProvides(array('virtual' => new Link('D', 'Virtual', $this->getVersionConstraint('==', '1.0'), 'provides'))); $packageD->setProvides(array('virtual' => new Link('D', 'Virtual', $this->getVersionConstraint('==', '1.0'), Link::TYPE_PROVIDE)));
$packageC->setRequires(array('a' => new Link('C', 'A', $this->getVersionConstraint('==', '1.0'), 'requires'))); $packageC->setRequires(array('a' => new Link('C', 'A', $this->getVersionConstraint('==', '1.0'), Link::TYPE_REQUIRE)));
$packageD->setRequires(array('a' => new Link('D', 'A', $this->getVersionConstraint('==', '1.0'), 'requires'))); $packageD->setRequires(array('a' => new Link('D', 'A', $this->getVersionConstraint('==', '1.0'), Link::TYPE_REQUIRE)));
$this->reposComplete(); $this->reposComplete();
@ -569,18 +569,18 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageD2 = $this->getPackage('D', '1.1')); $this->repo->addPackage($packageD2 = $this->getPackage('D', '1.1'));
$packageA->setRequires(array( $packageA->setRequires(array(
'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
'c' => new Link('A', 'C', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'c' => new Link('A', 'C', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageD->setReplaces(array( $packageD->setReplaces(array(
'b' => new Link('D', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces'), 'b' => new Link('D', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REPLACE),
'c' => new Link('D', 'C', $this->getVersionConstraint('>=', '1.0'), 'replaces'), 'c' => new Link('D', 'C', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REPLACE),
)); ));
$packageD2->setReplaces(array( $packageD2->setReplaces(array(
'b' => new Link('D', 'B', $this->getVersionConstraint('>=', '1.0'), 'replaces'), 'b' => new Link('D', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REPLACE),
'c' => new Link('D', 'C', $this->getVersionConstraint('>=', '1.0'), 'replaces'), 'c' => new Link('D', 'C', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REPLACE),
)); ));
$this->reposComplete(); $this->reposComplete();
@ -605,19 +605,19 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageD = $this->getPackage('D', '2.0.9')); $this->repo->addPackage($packageD = $this->getPackage('D', '2.0.9'));
$packageC->setRequires(array( $packageC->setRequires(array(
'a' => new Link('C', 'A', $this->getVersionConstraint('>=', '2.0'), 'requires'), 'a' => new Link('C', 'A', $this->getVersionConstraint('>=', '2.0'), Link::TYPE_REQUIRE),
'd' => new Link('C', 'D', $this->getVersionConstraint('>=', '2.0'), 'requires'), 'd' => new Link('C', 'D', $this->getVersionConstraint('>=', '2.0'), Link::TYPE_REQUIRE),
)); ));
$packageD->setRequires(array( $packageD->setRequires(array(
'a' => new Link('D', 'A', $this->getVersionConstraint('>=', '2.1'), 'requires'), 'a' => new Link('D', 'A', $this->getVersionConstraint('>=', '2.1'), Link::TYPE_REQUIRE),
'b' => new Link('D', 'B', $this->getVersionConstraint('>=', '2.0-dev'), 'requires'), 'b' => new Link('D', 'B', $this->getVersionConstraint('>=', '2.0-dev'), Link::TYPE_REQUIRE),
)); ));
$packageB1->setRequires(array('a' => new Link('B', 'A', $this->getVersionConstraint('==', '2.1.0.0-dev'), 'requires'))); $packageB1->setRequires(array('a' => new Link('B', 'A', $this->getVersionConstraint('==', '2.1.0.0-dev'), Link::TYPE_REQUIRE)));
$packageB2->setRequires(array('a' => new Link('B', 'A', $this->getVersionConstraint('==', '2.1.0.0-dev'), 'requires'))); $packageB2->setRequires(array('a' => new Link('B', 'A', $this->getVersionConstraint('==', '2.1.0.0-dev'), Link::TYPE_REQUIRE)));
$packageB2->setReplaces(array('d' => new Link('B', 'D', $this->getVersionConstraint('==', '2.0.9.0'), 'replaces'))); $packageB2->setReplaces(array('d' => new Link('B', 'D', $this->getVersionConstraint('==', '2.0.9.0'), Link::TYPE_REPLACE)));
$this->reposComplete(); $this->reposComplete();
@ -634,7 +634,7 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageA = $this->getPackage('A', '1.0')); $this->repo->addPackage($packageA = $this->getPackage('A', '1.0'));
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0')); $this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
$packageA->setConflicts(array( $packageA->setConflicts(array(
'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'conflicts'), 'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_CONFLICT),
)); ));
$this->reposComplete(); $this->reposComplete();
@ -668,7 +668,7 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0')); $this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
$packageA->setRequires(array( $packageA->setRequires(array(
'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '2.0'), 'requires'), 'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '2.0'), Link::TYPE_REQUIRE),
)); ));
$this->reposComplete(); $this->reposComplete();
@ -701,16 +701,16 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageD = $this->getPackage('D', '1.0')); $this->repo->addPackage($packageD = $this->getPackage('D', '1.0'));
$packageA->setRequires(array( $packageA->setRequires(array(
'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'b' => new Link('A', 'B', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageB->setRequires(array( $packageB->setRequires(array(
'c' => new Link('B', 'C', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'c' => new Link('B', 'C', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageC->setRequires(array( $packageC->setRequires(array(
'd' => new Link('C', 'D', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'd' => new Link('C', 'D', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageD->setRequires(array( $packageD->setRequires(array(
'b' => new Link('D', 'B', $this->getVersionConstraint('<', '1.0'), 'requires'), 'b' => new Link('D', 'B', $this->getVersionConstraint('<', '1.0'), Link::TYPE_REQUIRE),
)); ));
$this->reposComplete(); $this->reposComplete();
@ -749,11 +749,11 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageTwigBridge = $this->getPackage('symfony/twig-bridge', '2.0')); $this->repo->addPackage($packageTwigBridge = $this->getPackage('symfony/twig-bridge', '2.0'));
$packageTwigBridge->setRequires(array( $packageTwigBridge->setRequires(array(
'twig/twig' => new Link('symfony/twig-bridge', 'twig/twig', $this->getVersionConstraint('<', '2.0'), 'requires'), 'twig/twig' => new Link('symfony/twig-bridge', 'twig/twig', $this->getVersionConstraint('<', '2.0'), Link::TYPE_REQUIRE),
)); ));
$packageSymfony->setReplaces(array( $packageSymfony->setReplaces(array(
'symfony/twig-bridge' => new Link('symfony/symfony', 'symfony/twig-bridge', $this->getVersionConstraint('==', '2.0'), 'replaces'), 'symfony/twig-bridge' => new Link('symfony/symfony', 'symfony/twig-bridge', $this->getVersionConstraint('==', '2.0'), Link::TYPE_REPLACE),
)); ));
$this->reposComplete(); $this->reposComplete();
@ -774,10 +774,10 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageA2 = $this->getPackage('A', '2.0')); $this->repo->addPackage($packageA2 = $this->getPackage('A', '2.0'));
$packageA2->setRequires(array( $packageA2->setRequires(array(
'b' => new Link('A', 'B', $this->getVersionConstraint('==', '2.0'), 'requires', '== 2.0'), 'b' => new Link('A', 'B', $this->getVersionConstraint('==', '2.0'), Link::TYPE_REQUIRE, '== 2.0'),
)); ));
$packageB->setRequires(array( $packageB->setRequires(array(
'a' => new Link('B', 'A', $this->getVersionConstraint('>=', '2.0'), 'requires'), 'a' => new Link('B', 'A', $this->getVersionConstraint('>=', '2.0'), Link::TYPE_REQUIRE),
)); ));
$this->repo->addPackage($packageA2Alias = $this->getAliasPackage($packageA2, '1.1')); $this->repo->addPackage($packageA2Alias = $this->getAliasPackage($packageA2, '1.1'));
@ -799,7 +799,7 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageB = $this->getPackage('B', '1.0')); $this->repo->addPackage($packageB = $this->getPackage('B', '1.0'));
$packageB->setRequires(array( $packageB->setRequires(array(
'a' => new Link('B', 'A', $this->getVersionConstraint('<', '2.0'), 'requires'), 'a' => new Link('B', 'A', $this->getVersionConstraint('<', '2.0'), Link::TYPE_REQUIRE),
)); ));
$this->repo->addPackage($packageAAlias = $this->getAliasPackage($packageA, '1.1')); $this->repo->addPackage($packageAAlias = $this->getAliasPackage($packageA, '1.1'));
@ -840,29 +840,29 @@ class SolverTest extends TestCase
$this->repo->addPackage($packageG3 = $this->getPackage('G', '3.0')); $this->repo->addPackage($packageG3 = $this->getPackage('G', '3.0'));
$packageA->setRequires(array( $packageA->setRequires(array(
'b' => new Link('A', 'B', $this->getVersionConstraint('==', '1.0'), 'requires'), 'b' => new Link('A', 'B', $this->getVersionConstraint('==', '1.0'), Link::TYPE_REQUIRE),
'c' => new Link('A', 'C', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'c' => new Link('A', 'C', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
'd' => new Link('A', 'D', $this->getVersionConstraint('==', '1.0'), 'requires'), 'd' => new Link('A', 'D', $this->getVersionConstraint('==', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageB->setRequires(array( $packageB->setRequires(array(
'e' => new Link('B', 'E', $this->getVersionConstraint('==', '1.0'), 'requires'), 'e' => new Link('B', 'E', $this->getVersionConstraint('==', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageC1->setRequires(array( $packageC1->setRequires(array(
'f' => new Link('C', 'F', $this->getVersionConstraint('==', '1.0'), 'requires'), 'f' => new Link('C', 'F', $this->getVersionConstraint('==', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageC2->setRequires(array( $packageC2->setRequires(array(
'f' => new Link('C', 'F', $this->getVersionConstraint('==', '1.0'), 'requires'), 'f' => new Link('C', 'F', $this->getVersionConstraint('==', '1.0'), Link::TYPE_REQUIRE),
'g' => new Link('C', 'G', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'g' => new Link('C', 'G', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageD->setRequires(array( $packageD->setRequires(array(
'f' => new Link('D', 'F', $this->getVersionConstraint('>=', '1.0'), 'requires'), 'f' => new Link('D', 'F', $this->getVersionConstraint('>=', '1.0'), Link::TYPE_REQUIRE),
)); ));
$packageE->setRequires(array( $packageE->setRequires(array(
'g' => new Link('E', 'G', $this->getVersionConstraint('<=', '2.0'), 'requires'), 'g' => new Link('E', 'G', $this->getVersionConstraint('<=', '2.0'), Link::TYPE_REQUIRE),
)); ));
$this->reposComplete(); $this->reposComplete();

View File

@ -45,10 +45,10 @@ class TransactionTest extends TestCase
); );
$packageD->setRequires(array( $packageD->setRequires(array(
'f/f' => new Link('d/d', 'f/f', $this->getVersionConstraint('>', '0.2'), 'requires'), 'f/f' => new Link('d/d', 'f/f', $this->getVersionConstraint('>', '0.2'), Link::TYPE_REQUIRE),
'g/provider' => new Link('d/d', 'g/provider', $this->getVersionConstraint('>', '0.2'), 'requires'), 'g/provider' => new Link('d/d', 'g/provider', $this->getVersionConstraint('>', '0.2'), Link::TYPE_REQUIRE),
)); ));
$packageG->setProvides(array('g/provider' => new Link('g/g', 'g/provider', $this->getVersionConstraint('==', '1.0.0'), 'provides'))); $packageG->setProvides(array('g/provider' => new Link('g/g', 'g/provider', $this->getVersionConstraint('==', '1.0.0'), Link::TYPE_PROVIDE)));
$expectedOperations = array( $expectedOperations = array(
array('job' => 'uninstall', 'package' => $packageC), array('job' => 'uninstall', 'package' => $packageC),

View File

@ -145,11 +145,11 @@ class InstallerTest extends TestCase
$a = $this->getPackage('A', '1.0.0', 'Composer\Package\RootPackage'); $a = $this->getPackage('A', '1.0.0', 'Composer\Package\RootPackage');
$a->setRequires(array( $a->setRequires(array(
'b' => new Link('A', 'B', $v = $this->getVersionConstraint('=', '1.0.0'), 'requires', $v->getPrettyString()), 'b' => new Link('A', 'B', $v = $this->getVersionConstraint('=', '1.0.0'), Link::TYPE_REQUIRE, $v->getPrettyString()),
)); ));
$b = $this->getPackage('B', '1.0.0'); $b = $this->getPackage('B', '1.0.0');
$b->setRequires(array( $b->setRequires(array(
'a' => new Link('B', 'A', $v = $this->getVersionConstraint('=', '1.0.0'), 'requires', $v->getPrettyString()), 'a' => new Link('B', 'A', $v = $this->getVersionConstraint('=', '1.0.0'), Link::TYPE_REQUIRE, $v->getPrettyString()),
)); ));
$cases[] = array( $cases[] = array(
@ -165,11 +165,11 @@ class InstallerTest extends TestCase
$a = $this->getPackage('A', '1.0.0', 'Composer\Package\RootPackage'); $a = $this->getPackage('A', '1.0.0', 'Composer\Package\RootPackage');
$a->setRequires(array( $a->setRequires(array(
'b' => new Link('A', 'B', $v = $this->getVersionConstraint('=', '1.0.0'), 'requires', $v->getPrettyString()), 'b' => new Link('A', 'B', $v = $this->getVersionConstraint('=', '1.0.0'), Link::TYPE_REQUIRE, $v->getPrettyString()),
)); ));
$b = $this->getPackage('B', '1.0.0'); $b = $this->getPackage('B', '1.0.0');
$b->setRequires(array( $b->setRequires(array(
'a' => new Link('B', 'A', $v = $this->getVersionConstraint('=', '1.0.0'), 'requires', $v->getPrettyString()), 'a' => new Link('B', 'A', $v = $this->getVersionConstraint('=', '1.0.0'), Link::TYPE_REQUIRE, $v->getPrettyString()),
)); ));
$cases[] = array( $cases[] = array(

View File

@ -172,7 +172,7 @@ class ArrayDumperTest extends TestCase
), ),
array( array(
'require', 'require',
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0')), array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
'requires', 'requires',
array('foo/bar' => '1.0.0'), array('foo/bar' => '1.0.0'),
), ),
@ -197,13 +197,13 @@ class ArrayDumperTest extends TestCase
), ),
array( array(
'require', 'require',
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0')), array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
'requires', 'requires',
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'), array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
), ),
array( array(
'require-dev', 'require-dev',
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0')), array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
'devRequires', 'devRequires',
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'), array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
), ),
@ -215,19 +215,19 @@ class ArrayDumperTest extends TestCase
), ),
array( array(
'provide', 'provide',
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0')), array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
'provides', 'provides',
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'), array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
), ),
array( array(
'replace', 'replace',
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0')), array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
'replaces', 'replaces',
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'), array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
), ),
array( array(
'conflict', 'conflict',
array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), 'requires', '1.0.0')), array(new Link('foo', 'foo/bar', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0'), new Link('bar', 'bar/baz', new Constraint('=', '1.0.0.0'), Link::TYPE_REQUIRE, '1.0.0')),
'conflicts', 'conflicts',
array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'), array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0'),
), ),

View File

@ -57,9 +57,9 @@ class VersionSelectorTest extends TestCase
$parser = new VersionParser; $parser = new VersionParser;
$package1 = $this->createPackage('1.0.0'); $package1 = $this->createPackage('1.0.0');
$package1->setRequires(array('php' => new Link($packageName, 'php', $parser->parseConstraints('>=5.4'), 'requires', '>=5.4'))); $package1->setRequires(array('php' => new Link($packageName, 'php', $parser->parseConstraints('>=5.4'), Link::TYPE_REQUIRE, '>=5.4')));
$package2 = $this->createPackage('2.0.0'); $package2 = $this->createPackage('2.0.0');
$package2->setRequires(array('php' => new Link($packageName, 'php', $parser->parseConstraints('>=5.6'), 'requires', '>=5.6'))); $package2->setRequires(array('php' => new Link($packageName, 'php', $parser->parseConstraints('>=5.6'), Link::TYPE_REQUIRE, '>=5.6')));
$packages = array($package1, $package2); $packages = array($package1, $package2);
$repositorySet->expects($this->any()) $repositorySet->expects($this->any())
@ -83,9 +83,9 @@ class VersionSelectorTest extends TestCase
$parser = new VersionParser; $parser = new VersionParser;
$package1 = $this->createPackage('1.0.0'); $package1 = $this->createPackage('1.0.0');
$package1->setRequires(array('ext-zip' => new Link($packageName, 'ext-zip', $parser->parseConstraints('^5.2'), 'requires', '^5.2'))); $package1->setRequires(array('ext-zip' => new Link($packageName, 'ext-zip', $parser->parseConstraints('^5.2'), Link::TYPE_REQUIRE, '^5.2')));
$package2 = $this->createPackage('2.0.0'); $package2 = $this->createPackage('2.0.0');
$package2->setRequires(array('ext-zip' => new Link($packageName, 'ext-zip', $parser->parseConstraints('^5.4'), 'requires', '^5.4'))); $package2->setRequires(array('ext-zip' => new Link($packageName, 'ext-zip', $parser->parseConstraints('^5.4'), Link::TYPE_REQUIRE, '^5.4')));
$packages = array($package1, $package2); $packages = array($package1, $package2);
$repositorySet->expects($this->any()) $repositorySet->expects($this->any())
@ -109,9 +109,9 @@ class VersionSelectorTest extends TestCase
$parser = new VersionParser; $parser = new VersionParser;
$package1 = $this->createPackage('1.0.0'); $package1 = $this->createPackage('1.0.0');
$package1->setRequires(array('composer-runtime-api' => new Link($packageName, 'composer-runtime-api', $parser->parseConstraints('^1.0'), 'requires', '^1.0'))); $package1->setRequires(array('composer-runtime-api' => new Link($packageName, 'composer-runtime-api', $parser->parseConstraints('^1.0'), Link::TYPE_REQUIRE, '^1.0')));
$package2 = $this->createPackage('1.1.0'); $package2 = $this->createPackage('1.1.0');
$package2->setRequires(array('composer-runtime-api' => new Link($packageName, 'composer-runtime-api', $parser->parseConstraints('^2.0'), 'requires', '^2.0'))); $package2->setRequires(array('composer-runtime-api' => new Link($packageName, 'composer-runtime-api', $parser->parseConstraints('^2.0'), Link::TYPE_REQUIRE, '^2.0')));
$packages = array($package1, $package2); $packages = array($package1, $package2);
$repositorySet->expects($this->any()) $repositorySet->expects($this->any())