RequestTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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\DependencyResolver;
  12. use Composer\DependencyResolver\Request;
  13. use Composer\Repository\ArrayRepository;
  14. use Composer\Test\TestCase;
  15. class RequestTest extends TestCase
  16. {
  17. public function testRequestInstall()
  18. {
  19. $repo = new ArrayRepository;
  20. $foo = $this->getPackage('foo', '1');
  21. $bar = $this->getPackage('bar', '1');
  22. $foobar = $this->getPackage('foobar', '1');
  23. $repo->addPackage($foo);
  24. $repo->addPackage($bar);
  25. $repo->addPackage($foobar);
  26. $request = new Request();
  27. $request->requireName('foo');
  28. $this->assertEquals(
  29. array(
  30. 'foo' => null,
  31. ),
  32. $request->getRequires()
  33. );
  34. }
  35. public function testRequestInstallSamePackageFromDifferentRepositories()
  36. {
  37. $repo1 = new ArrayRepository;
  38. $repo2 = new ArrayRepository;
  39. $foo1 = $this->getPackage('foo', '1');
  40. $foo2 = $this->getPackage('foo', '1');
  41. $repo1->addPackage($foo1);
  42. $repo2->addPackage($foo2);
  43. $request = new Request();
  44. $request->requireName('foo', $constraint = $this->getVersionConstraint('=', '1'));
  45. $this->assertEquals(
  46. array(
  47. 'foo' => $constraint,
  48. ),
  49. $request->getRequires()
  50. );
  51. }
  52. }