Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

More integration tests #685

Merged
merged 4 commits into from May 13, 2012
@@ -61,6 +61,6 @@ public function getJobType()
*/
public function __toString()
{
- return 'Marking '.$this->package->getPrettyName().' ('.$this->package->getPrettyVersion().') as installed, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->package->getAliasOf()->getPrettyVersion().')';
+ return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as installed, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')';
}
}
@@ -61,6 +61,6 @@ public function getJobType()
*/
public function __toString()
{
- return 'Marking '.$this->package->getPrettyName().' ('.$this->package->getPrettyVersion().') as uninstalled, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->package->getAliasOf()->getPrettyVersion().')';
+ return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as uninstalled, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')';
}
}
@@ -0,0 +1,53 @@
+--TEST--
+Aliases take precedence over default package
+--COMPOSER--
+{
+ "repositories": [
+ {
+ "type": "package",
+ "package": [
+ {
+ "name": "a/c", "version": "dev-feature-foo",
+ "source": { "reference": "feat.f", "type": "git", "url": "" }
+ },
+ {
+ "name": "a/b", "version": "dev-master",
+ "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } },
+ "source": { "reference": "forked", "type": "git", "url": "" }
+ }
+ ]
+ },
+ {
+ "type": "package",
+ "package": [
+ {
+ "name": "a/a", "version": "dev-master",
+ "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } },
+ "source": { "reference": "master", "type": "git", "url": "" },
+ "require": {
+ "a/b": "dev-master",
+ "a/c": "dev-master"
+ }
+ },
+ {
+ "name": "a/b", "version": "dev-master",
+ "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } },
+ "source": { "reference": "master", "type": "git", "url": "" }
+ },
+ { "name": "a/c", "version": "dev-master" }
+ ]
+ }
+ ],
+ "require": {
+ "a/a": "1.*",
+ "a/b": "1.*",
+ "a/c": "dev-feature-foo as dev-master"
+ }
+}
+--EXPECT--
+Installing a/c (dev-feature-foo feat.f)
+Marking a/c (dev-master feat.f) as installed, alias of a/c (dev-feature-foo feat.f)
+Installing a/b (dev-master forked)
+Marking a/b (1.0.x-dev forked) as installed, alias of a/b (dev-master forked)
+Installing a/a (dev-master master)
+Marking a/a (1.0.x-dev master) as installed, alias of a/a (dev-master master)
@@ -196,13 +196,14 @@ public function getIntegrationTests()
$test = file_get_contents($file->getRealpath());
+ $content = '(?:.(?!--[A-Z]))+';
$pattern = '{^
--TEST--\s*(?P<test>.*?)\s*
- (?:--CONDITION--\s*(?P<condition>.*?))?\s*
- --COMPOSER--\s*(?P<composer>.*?)\s*
- (?:--LOCK--\s*(?P<lock>.*?))?\s*
- (?:--INSTALLED--\s*(?P<installed>.*?))?\s*
- (?:--INSTALLED:DEV--\s*(?P<installedDev>.*?))?\s*
+ (?:--CONDITION--\s*(?P<condition>'.$content.'))?\s*
+ --COMPOSER--\s*(?P<composer>'.$content.')\s*
+ (?:--LOCK--\s*(?P<lock>'.$content.'))?\s*
+ (?:--INSTALLED--\s*(?P<installed>'.$content.'))?\s*
+ (?:--INSTALLED:DEV--\s*(?P<installedDev>'.$content.'))?\s*
--EXPECT(?P<update>:UPDATE)?(?P<dev>:DEV)?--\s*(?P<expect>.*?)\s*
$}xs';
@@ -17,6 +17,8 @@
use Composer\DependencyResolver\Operation\InstallOperation;
use Composer\DependencyResolver\Operation\UpdateOperation;
use Composer\DependencyResolver\Operation\UninstallOperation;
+use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
+use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
class InstallationManagerMock extends InstallationManager
{
@@ -47,6 +49,20 @@ public function uninstall(RepositoryInterface $repo, UninstallOperation $operati
$repo->removePackage($operation->getPackage());
}
+ public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
+ {
+ $this->installed[] = $operation->getPackage();
+ $this->trace[] = (string) $operation;
+ $repo->addPackage(clone $operation->getPackage());
+ }
+
+ public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
+ {
+ $this->uninstalled[] = $operation->getPackage();
+ $this->trace[] = (string) $operation;
+ $repo->removePackage($operation->getPackage());
+ }
+
public function getTrace()
{
return $this->trace;