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\Pool;
|
2011-04-17 21:45:37 +00:00
|
|
|
use Composer\Repository\ArrayRepository;
|
2012-05-11 15:21:02 +00:00
|
|
|
use Composer\Package\BasePackage;
|
2018-11-12 14:23:32 +00:00
|
|
|
use Composer\Test\TestCase;
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2011-11-20 14:06:12 +00:00
|
|
|
class PoolTest extends TestCase
|
2011-04-05 15:37:19 +00:00
|
|
|
{
|
|
|
|
public function testPool()
|
|
|
|
{
|
2018-09-11 11:33:29 +00:00
|
|
|
$pool = $this->createPool();
|
2011-11-20 14:06:12 +00:00
|
|
|
$package = $this->getPackage('foo', '1');
|
2011-04-05 15:37:19 +00:00
|
|
|
|
2018-09-12 09:49:09 +00:00
|
|
|
$pool->setPackages(array($package));
|
2011-04-05 15:37:19 +00:00
|
|
|
|
|
|
|
$this->assertEquals(array($package), $pool->whatProvides('foo'));
|
|
|
|
$this->assertEquals(array($package), $pool->whatProvides('foo'));
|
|
|
|
}
|
2012-01-22 21:06:09 +00:00
|
|
|
|
2012-03-06 09:11:45 +00:00
|
|
|
public function testWhatProvidesPackageWithConstraint()
|
|
|
|
{
|
2018-09-11 11:33:29 +00:00
|
|
|
$pool = $this->createPool();
|
2012-03-06 09:11:45 +00:00
|
|
|
|
|
|
|
$firstPackage = $this->getPackage('foo', '1');
|
|
|
|
$secondPackage = $this->getPackage('foo', '2');
|
|
|
|
|
2018-09-12 09:49:09 +00:00
|
|
|
$pool->setPackages(array(
|
|
|
|
$firstPackage,
|
|
|
|
$secondPackage,
|
|
|
|
));
|
2012-03-06 09:11:45 +00:00
|
|
|
|
|
|
|
$this->assertEquals(array($firstPackage, $secondPackage), $pool->whatProvides('foo'));
|
|
|
|
$this->assertEquals(array($secondPackage), $pool->whatProvides('foo', $this->getVersionConstraint('==', '2')));
|
2012-01-22 21:06:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testPackageById()
|
|
|
|
{
|
2018-09-11 11:33:29 +00:00
|
|
|
$pool = $this->createPool();
|
2012-01-22 21:06:09 +00:00
|
|
|
$package = $this->getPackage('foo', '1');
|
|
|
|
|
2018-09-12 09:49:09 +00:00
|
|
|
$pool->setPackages(array($package));
|
2012-01-22 21:06:09 +00:00
|
|
|
|
|
|
|
$this->assertSame($package, $pool->packageById(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testWhatProvidesWhenPackageCannotBeFound()
|
|
|
|
{
|
2018-09-11 11:33:29 +00:00
|
|
|
$pool = $this->createPool();
|
2012-01-22 21:06:09 +00:00
|
|
|
|
|
|
|
$this->assertEquals(array(), $pool->whatProvides('foo'));
|
|
|
|
}
|
2018-09-11 11:33:29 +00:00
|
|
|
|
|
|
|
protected function createPool()
|
|
|
|
{
|
2019-11-27 16:55:02 +00:00
|
|
|
return new Pool();
|
2018-09-11 11:33:29 +00:00
|
|
|
}
|
2011-04-05 15:37:19 +00:00
|
|
|
}
|