RequestTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\DependencyResolver\Pool;
  14. use Composer\Repository\ArrayRepository;
  15. use Composer\DependencyResolver\Literal;
  16. use Composer\Test\TestCase;
  17. class RequestTest extends TestCase
  18. {
  19. public function testRequestInstallAndRemove()
  20. {
  21. $pool = new Pool;
  22. $repo = new ArrayRepository;
  23. $foo = $this->getPackage('foo', '1');
  24. $bar = $this->getPackage('bar', '1');
  25. $foobar = $this->getPackage('foobar', '1');
  26. $repo->addPackage($foo);
  27. $repo->addPackage($bar);
  28. $repo->addPackage($foobar);
  29. $pool->addRepository($repo);
  30. $request = new Request($pool);
  31. $request->install('foo');
  32. $request->install('bar');
  33. $request->remove('foobar');
  34. $this->assertEquals(
  35. array(
  36. array('packages' => array($foo), 'cmd' => 'install', 'packageName' => 'foo'),
  37. array('packages' => array($bar), 'cmd' => 'install', 'packageName' => 'bar'),
  38. array('packages' => array($foobar), 'cmd' => 'remove', 'packageName' => 'foobar'),
  39. ),
  40. $request->getJobs());
  41. }
  42. }