1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

Add InstalledRepository to clean up some concepts and usages, remove BaseRepository

This commit is contained in:
Jordi Boggiano 2020-02-13 21:44:24 +01:00
parent 78885c556a
commit 2d8a8ed7e3
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
10 changed files with 184 additions and 113 deletions

View file

@ -0,0 +1,51 @@
<?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\Repository;
use Composer\Repository\InstalledRepository;
use Composer\Repository\ArrayRepository;
use Composer\Repository\InstalledArrayRepository;
use Composer\Package\Link;
use Composer\Test\TestCase;
class InstalledRepositoryTest extends TestCase
{
public function testFindPackagesWithReplacersAndProviders()
{
$arrayRepoOne = new InstalledArrayRepository;
$arrayRepoOne->addPackage($foo = $this->getPackage('foo', '1'));
$arrayRepoOne->addPackage($foo2 = $this->getPackage('foo', '2'));
$arrayRepoTwo = new InstalledArrayRepository;
$arrayRepoTwo->addPackage($bar = $this->getPackage('bar', '1'));
$arrayRepoTwo->addPackage($bar2 = $this->getPackage('bar', '2'));
$foo->setReplaces(array(new Link('foo', 'provided')));
$bar2->setProvides(array(new Link('bar', 'provided')));
$repo = new InstalledRepository(array($arrayRepoOne, $arrayRepoTwo));
$this->assertEquals(array($foo2), $repo->findPackagesWithReplacersAndProviders('foo', '2'));
$this->assertEquals(array($bar), $repo->findPackagesWithReplacersAndProviders('bar', '1'));
$this->assertEquals(array($foo, $bar2), $repo->findPackagesWithReplacersAndProviders('provided'));
}
public function testAddRepository()
{
$arrayRepoOne = new ArrayRepository;
$this->setExpectedException('LogicException');
new InstalledRepository(array($arrayRepoOne));
}
}