ArchiverTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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\Package\Archiver;
  12. use Composer\Test\TestCase;
  13. use Composer\Util\Filesystem;
  14. use Composer\Util\ProcessExecutor;
  15. use Composer\Package\Package;
  16. abstract class ArchiverTest extends TestCase
  17. {
  18. /**
  19. * @var \Composer\Util\Filesystem
  20. */
  21. protected $filesystem;
  22. /**
  23. * @var \Composer\Util\ProcessExecutor
  24. */
  25. protected $process;
  26. /**
  27. * @var string
  28. */
  29. protected $testDir;
  30. public function setUp()
  31. {
  32. $this->filesystem = new Filesystem();
  33. $this->process = new ProcessExecutor();
  34. $this->testDir = $this->getUniqueTmpDirectory();
  35. }
  36. public function tearDown()
  37. {
  38. $this->filesystem->removeDirectory($this->testDir);
  39. }
  40. /**
  41. * Util method to quickly setup a package using the source path built.
  42. *
  43. * @return \Composer\Package\Package
  44. */
  45. protected function setupPackage()
  46. {
  47. $package = new Package('archivertest/archivertest', 'master', 'master');
  48. $package->setSourceUrl(realpath($this->testDir));
  49. $package->setSourceReference('master');
  50. $package->setSourceType('git');
  51. return $package;
  52. }
  53. }