2015-10-27 02:59:05 +00:00
|
|
|
<?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\Link;
|
|
|
|
use Composer\Package\RootAliasPackage;
|
2020-06-05 14:41:37 +00:00
|
|
|
use Composer\Semver\Constraint\MatchAllConstraint;
|
2018-11-12 14:23:32 +00:00
|
|
|
use Composer\Test\TestCase;
|
2015-10-27 02:59:05 +00:00
|
|
|
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());
|
2021-08-21 15:41:52 +00:00
|
|
|
$links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_REQUIRE, 'self.version'));
|
2015-10-27 02:59:05 +00:00
|
|
|
$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());
|
2021-08-21 15:41:52 +00:00
|
|
|
$links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_DEV_REQUIRE, 'self.version'));
|
2015-10-27 02:59:05 +00:00
|
|
|
$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());
|
2021-08-21 15:41:52 +00:00
|
|
|
$links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_CONFLICT, 'self.version'));
|
2015-10-27 02:59:05 +00:00
|
|
|
$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());
|
2021-08-21 15:41:52 +00:00
|
|
|
$links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_PROVIDE, 'self.version'));
|
2015-10-27 02:59:05 +00:00
|
|
|
$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());
|
2021-08-21 15:41:52 +00:00
|
|
|
$links = array(new Link('a', 'b', new MatchAllConstraint(), Link::TYPE_REPLACE, 'self.version'));
|
2015-10-27 02:59:05 +00:00
|
|
|
$alias->setReplaces($links);
|
|
|
|
$this->assertNotEmpty($alias->getReplaces());
|
|
|
|
}
|
|
|
|
|
2021-11-01 20:44:12 +00:00
|
|
|
/**
|
|
|
|
* @return \Prophecy\Prophecy\ObjectProphecy
|
|
|
|
*/
|
2015-10-27 02:59:05 +00:00
|
|
|
protected function getMockRootPackageInterface()
|
|
|
|
{
|
2021-03-09 14:49:40 +00:00
|
|
|
$root = $this->prophesize('Composer\\Package\\RootPackage');
|
2015-10-27 02:59:05 +00:00
|
|
|
$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();
|
2015-11-21 19:28:10 +00:00
|
|
|
|
2015-10-27 02:59:05 +00:00
|
|
|
return $root;
|
|
|
|
}
|
|
|
|
}
|