ArchiverTest.php 1.6 KB

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