1
0
Fork 0

Settings of the same repository for a package is allowed.

pull/1573/head
Martin Hasoň 2013-03-21 12:33:02 +01:00
parent 02f92e678f
commit fa0d62ab6a
3 changed files with 43 additions and 2 deletions

View File

@ -817,7 +817,6 @@ class Installer
if ($package instanceof AliasPackage) { if ($package instanceof AliasPackage) {
$alias = (string) $package->getAliasOf(); $alias = (string) $package->getAliasOf();
$packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion()); $packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
unset($packages[$alias]);
} }
} }
$rm->setLocalRepository( $rm->setLocalRepository(

View File

@ -119,7 +119,7 @@ abstract class BasePackage implements PackageInterface
*/ */
public function setRepository(RepositoryInterface $repository) public function setRepository(RepositoryInterface $repository)
{ {
if ($this->repository) { if ($this->repository && $repository !== $this->repository) {
throw new \LogicException('A package can only be added to one repository'); throw new \LogicException('A package can only be added to one repository');
} }
$this->repository = $repository; $this->repository = $repository;

View File

@ -0,0 +1,42 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Test\Package;
use Composer\Package\BasePackage;
class BasePackageTest extends \PHPUnit_Framework_TestCase
{
public function testSetSameRepository()
{
$package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo'));
$repository = $this->getMock('Composer\Repository\RepositoryInterface');
$package->setRepository($repository);
try {
$package->setRepository($repository);
} catch (\Exception $e) {
$this->fail('Set againt the same repository is allowed.');
}
}
/**
* @expectedException LogicException
*/
public function testSetAnotherRepository()
{
$package = $this->getMockForAbstractClass('Composer\Package\BasePackage', array('foo'));
$package->setRepository($this->getMock('Composer\Repository\RepositoryInterface'));
$package->setRepository($this->getMock('Composer\Repository\RepositoryInterface'));
}
}