InstalledRepositoryTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\Repository;
  12. use Composer\Repository\InstalledRepository;
  13. use Composer\Repository\ArrayRepository;
  14. use Composer\Repository\InstalledArrayRepository;
  15. use Composer\Package\Link;
  16. use Composer\Test\TestCase;
  17. class InstalledRepositoryTest extends TestCase
  18. {
  19. public function testFindPackagesWithReplacersAndProviders()
  20. {
  21. $arrayRepoOne = new InstalledArrayRepository;
  22. $arrayRepoOne->addPackage($foo = $this->getPackage('foo', '1'));
  23. $arrayRepoOne->addPackage($foo2 = $this->getPackage('foo', '2'));
  24. $arrayRepoTwo = new InstalledArrayRepository;
  25. $arrayRepoTwo->addPackage($bar = $this->getPackage('bar', '1'));
  26. $arrayRepoTwo->addPackage($bar2 = $this->getPackage('bar', '2'));
  27. $foo->setReplaces(array(new Link('foo', 'provided')));
  28. $bar2->setProvides(array(new Link('bar', 'provided')));
  29. $repo = new InstalledRepository(array($arrayRepoOne, $arrayRepoTwo));
  30. $this->assertEquals(array($foo2), $repo->findPackagesWithReplacersAndProviders('foo', '2'));
  31. $this->assertEquals(array($bar), $repo->findPackagesWithReplacersAndProviders('bar', '1'));
  32. $this->assertEquals(array($foo, $bar2), $repo->findPackagesWithReplacersAndProviders('provided'));
  33. }
  34. public function testAddRepository()
  35. {
  36. $arrayRepoOne = new ArrayRepository;
  37. $this->setExpectedException('LogicException');
  38. new InstalledRepository(array($arrayRepoOne));
  39. }
  40. }