2011-04-05 15:37:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2011-04-16 12:42:35 +00:00
|
|
|
* This file is part of Composer.
|
2011-04-05 15:37:19 +00:00
|
|
|
*
|
2011-04-16 12:42:35 +00:00
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
2011-04-05 15:37:19 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Composer\Test\DependencyResolver;
|
|
|
|
|
|
|
|
use Composer\DependencyResolver\Request;
|
2011-04-17 21:45:37 +00:00
|
|
|
use Composer\Repository\ArrayRepository;
|
2013-09-25 08:14:42 +00:00
|
|
|
use Composer\TestCase;
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2011-11-20 14:06:12 +00:00
|
|
|
class RequestTest extends TestCase
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
|
|
|
public function testRequestInstallAndRemove()
|
|
|
|
{
|
|
|
|
$repo = new ArrayRepository;
|
2011-11-20 14:06:12 +00:00
|
|
|
$foo = $this->getPackage('foo', '1');
|
|
|
|
$bar = $this->getPackage('bar', '1');
|
|
|
|
$foobar = $this->getPackage('foobar', '1');
|
2011-04-05 15:37:19 +00:00
|
|
|
|
|
|
|
$repo->addPackage($foo);
|
|
|
|
$repo->addPackage($bar);
|
|
|
|
$repo->addPackage($foobar);
|
|
|
|
|
2015-04-30 15:24:24 +00:00
|
|
|
$request = new Request();
|
2011-04-05 15:37:19 +00:00
|
|
|
$request->install('foo');
|
2014-10-17 14:26:00 +00:00
|
|
|
$request->fix('bar');
|
2011-04-05 15:37:19 +00:00
|
|
|
$request->remove('foobar');
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
array(
|
2014-10-17 14:26:00 +00:00
|
|
|
array('cmd' => 'install', 'packageName' => 'foo', 'constraint' => null, 'fixed' => false),
|
|
|
|
array('cmd' => 'install', 'packageName' => 'bar', 'constraint' => null, 'fixed' => true),
|
|
|
|
array('cmd' => 'remove', 'packageName' => 'foobar', 'constraint' => null, 'fixed' => false),
|
2011-04-05 15:37:19 +00:00
|
|
|
),
|
|
|
|
$request->getJobs());
|
|
|
|
}
|
2012-02-19 15:59:04 +00:00
|
|
|
|
2012-03-06 09:11:45 +00:00
|
|
|
public function testRequestInstallSamePackageFromDifferentRepositories()
|
|
|
|
{
|
|
|
|
$repo1 = new ArrayRepository;
|
|
|
|
$repo2 = new ArrayRepository;
|
|
|
|
|
|
|
|
$foo1 = $this->getPackage('foo', '1');
|
|
|
|
$foo2 = $this->getPackage('foo', '1');
|
|
|
|
|
|
|
|
$repo1->addPackage($foo1);
|
|
|
|
$repo2->addPackage($foo2);
|
|
|
|
|
2015-04-30 15:24:24 +00:00
|
|
|
$request = new Request();
|
2012-03-18 19:41:10 +00:00
|
|
|
$request->install('foo', $constraint = $this->getVersionConstraint('=', '1'));
|
2012-03-06 09:11:45 +00:00
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
array(
|
2014-10-17 14:26:00 +00:00
|
|
|
array('cmd' => 'install', 'packageName' => 'foo', 'constraint' => $constraint, 'fixed' => false),
|
2012-03-06 09:11:45 +00:00
|
|
|
),
|
|
|
|
$request->getJobs()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-02-19 15:59:04 +00:00
|
|
|
public function testUpdateAll()
|
|
|
|
{
|
2015-04-30 15:24:24 +00:00
|
|
|
$request = new Request();
|
2012-02-19 15:59:04 +00:00
|
|
|
|
|
|
|
$request->updateAll();
|
|
|
|
|
|
|
|
$this->assertEquals(
|
2014-02-21 12:41:21 +00:00
|
|
|
array(array('cmd' => 'update-all')),
|
2012-02-19 15:59:04 +00:00
|
|
|
$request->getJobs());
|
|
|
|
}
|
2011-04-05 15:37:19 +00:00
|
|
|
}
|