GitArchiverTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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\Package\Archiver\GitArchiver;
  13. /**
  14. * @author Till Klampaeckel <till@php.net>
  15. * @author Matthieu Moquet <matthieu@moquet.net>
  16. */
  17. class GitArchiverTest extends ArchiverTest
  18. {
  19. public function testZipArchive()
  20. {
  21. $this->setupGitRepo();
  22. $package = $this->setupPackage();
  23. $target = sys_get_temp_dir().'/composer_archiver_test.zip';
  24. // Test archive
  25. $archiver = new GitArchiver();
  26. $archiver->setFormat('zip');
  27. $archiver->setSourceRef('master');
  28. $archiver->archive($package->getSourceUrl(), $target);
  29. $this->assertFileExists($target);
  30. unlink($target);
  31. $this->removeGitRepo();
  32. }
  33. public function testTarArchive()
  34. {
  35. $this->setupGitRepo();
  36. $package = $this->setupPackage();
  37. $target = sys_get_temp_dir().'/composer_archiver_test.tar';
  38. // Test archive
  39. $archiver = new GitArchiver();
  40. $archiver->setFormat('tar');
  41. $archiver->setSourceRef('master');
  42. $archiver->archive($package->getSourceUrl(), $target);
  43. $this->assertFileExists($target);
  44. unlink($target);
  45. $this->removeGitRepo();
  46. }
  47. }