InstallationManagerMock.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\Mock;
  12. use Composer\Installer\InstallationManager;
  13. use Composer\Repository\RepositoryInterface;
  14. use Composer\DependencyResolver\Operation\OperationInterface;
  15. use Composer\DependencyResolver\Operation\InstallOperation;
  16. use Composer\DependencyResolver\Operation\UpdateOperation;
  17. use Composer\DependencyResolver\Operation\UninstallOperation;
  18. class InstallationManagerMock extends InstallationManager
  19. {
  20. private $installed = array();
  21. private $updated = array();
  22. private $uninstalled = array();
  23. private $trace = array();
  24. public function install(RepositoryInterface $repo, InstallOperation $operation)
  25. {
  26. $this->installed[] = $operation->getPackage();
  27. $this->trace[] = (string) $operation;
  28. $repo->addPackage(clone $operation->getPackage());
  29. }
  30. public function update(RepositoryInterface $repo, UpdateOperation $operation)
  31. {
  32. $this->updated[] = array($operation->getInitialPackage(), $operation->getTargetPackage());
  33. $this->trace[] = (string) $operation;
  34. $repo->removePackage($operation->getInitialPackage());
  35. $repo->addPackage(clone $operation->getTargetPackage());
  36. }
  37. public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
  38. {
  39. $this->uninstalled[] = $operation->getPackage();
  40. $this->trace[] = (string) $operation;
  41. $repo->removePackage($operation->getPackage());
  42. }
  43. public function getTrace()
  44. {
  45. return $this->trace;
  46. }
  47. public function getInstalledPackages()
  48. {
  49. return $this->installed;
  50. }
  51. public function getUpdatedPackages()
  52. {
  53. return $this->updated;
  54. }
  55. public function getUninstalledPackages()
  56. {
  57. return $this->uninstalled;
  58. }
  59. }