diff --git a/src/Composer/Package/RootAliasPackage.php b/src/Composer/Package/RootAliasPackage.php index 9c723aa53..e66342136 100644 --- a/src/Composer/Package/RootAliasPackage.php +++ b/src/Composer/Package/RootAliasPackage.php @@ -109,6 +109,54 @@ class RootAliasPackage extends AliasPackage implements RootPackageInterface $this->aliasOf->setReplaces($replaces); } + /** + * {@inheritDoc} + */ + public function setRepositories($repositories) + { + $this->aliasOf->setRepositories($repositories); + } + + /** + * {@inheritDoc} + */ + public function setAutoload(array $autoload) + { + $this->aliasOf->setAutoload($autoload); + } + + /** + * {@inheritDoc} + */ + public function setDevAutoload(array $devAutoload) + { + $this->aliasOf->setDevAutoload($devAutoload); + } + + /** + * {@inheritDoc} + */ + public function setStabilityFlags(array $stabilityFlags) + { + $this->aliasOf->setStabilityFlags($stabilityFlags); + } + + /** + * {@inheritDoc} + */ + public function setSuggests(array $suggests) + { + $this->aliasOf->setSuggests($suggests); + } + + /** + * {@inheritDoc} + */ + public function setExtra(array $extra) + { + $this->aliasOf->setExtra($extra); + } + public function __clone() { parent::__clone(); diff --git a/src/Composer/Package/RootPackageInterface.php b/src/Composer/Package/RootPackageInterface.php index 7d39ff7bc..5f59a3717 100644 --- a/src/Composer/Package/RootPackageInterface.php +++ b/src/Composer/Package/RootPackageInterface.php @@ -71,4 +71,65 @@ interface RootPackageInterface extends CompletePackageInterface * @param array $devRequires A set of package links */ public function setDevRequires(array $devRequires); + + /** + * Set the conflicting packages + * + * @param array $conflicts A set of package links + */ + public function setConflicts(array $conflicts); + + /** + * Set the provided virtual packages + * + * @param array $provides A set of package links + */ + public function setProvides(array $provides); + + /** + * Set the packages this one replaces + * + * @param array $replaces A set of package links + */ + public function setReplaces(array $replaces); + + /** + * Set the repositories + * + * @param array $repositories + */ + public function setRepositories($repositories); + + /** + * Set the autoload mapping + * + * @param array $autoload Mapping of autoloading rules + */ + public function setAutoload(array $autoload); + + /** + * Set the dev autoload mapping + * + * @param array $devAutoload Mapping of dev autoloading rules + */ + public function setDevAutoload(array $devAutoload); + + /** + * Set the stabilityFlags + * + * @param array $stabilityFlags + */ + public function setStabilityFlags(array $stabilityFlags); + + /** + * Set the suggested packages + * + * @param array $suggests A set of package names/comments + */ + public function setSuggests(array $suggests); + + /** + * @param array $extra + */ + public function setExtra(array $extra); } diff --git a/tests/Composer/Test/Package/RootAliasPackageTest.php b/tests/Composer/Test/Package/RootAliasPackageTest.php new file mode 100644 index 000000000..bc7bb1d98 --- /dev/null +++ b/tests/Composer/Test/Package/RootAliasPackageTest.php @@ -0,0 +1,94 @@ + + * Jordi Boggiano + * + * 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\Link; +use Composer\Package\RootAliasPackage; +use Composer\TestCase; +use Prophecy\Argument; + +class RootAliasPackageTest extends TestCase +{ + + public function testUpdateRequires() + { + $root = $this->getMockRootPackageInterface(); + $root->setRequires(Argument::type('array'))->shouldBeCalled(); + + $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getRequires()); + $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $alias->setRequires($links); + $this->assertNotEmpty($alias->getRequires()); + } + + public function testUpdateDevRequires() + { + $root = $this->getMockRootPackageInterface(); + $root->setDevRequires(Argument::type('array'))->shouldBeCalled(); + + $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getDevRequires()); + $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $alias->setDevRequires($links); + $this->assertNotEmpty($alias->getDevRequires()); + } + + public function testUpdateConflicts() + { + $root = $this->getMockRootPackageInterface(); + $root->setConflicts(Argument::type('array'))->shouldBeCalled(); + + $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getConflicts()); + $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $alias->setConflicts($links); + $this->assertNotEmpty($alias->getConflicts()); + } + + public function testUpdateProvides() + { + $root = $this->getMockRootPackageInterface(); + $root->setProvides(Argument::type('array'))->shouldBeCalled(); + + $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getProvides()); + $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $alias->setProvides($links); + $this->assertNotEmpty($alias->getProvides()); + } + + public function testUpdateReplaces() + { + $root = $this->getMockRootPackageInterface(); + $root->setReplaces(Argument::type('array'))->shouldBeCalled(); + + $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); + $this->assertEmpty($alias->getReplaces()); + $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $alias->setReplaces($links); + $this->assertNotEmpty($alias->getReplaces()); + } + + protected function getMockRootPackageInterface() + { + $root = $this->prophesize('Composer\\Package\\RootPackageInterface'); + $root->getName()->willReturn('something/something')->shouldBeCalled(); + $root->getRequires()->willReturn(array())->shouldBeCalled(); + $root->getDevRequires()->willReturn(array())->shouldBeCalled(); + $root->getConflicts()->willReturn(array())->shouldBeCalled(); + $root->getProvides()->willReturn(array())->shouldBeCalled(); + $root->getReplaces()->willReturn(array())->shouldBeCalled(); + return $root; + } +}