ZipDownloaderTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Downloader;
  12. use Composer\Util\Filesystem;
  13. use Composer\Downloader\ZipDownloader;
  14. class ZipDownloaderTest extends \PHPUnit_Framework_TestCase
  15. {
  16. public function setUp()
  17. {
  18. if (!class_exists('ZipArchive')) {
  19. $this->markTestSkipped('zip extension missing');
  20. }
  21. }
  22. public function testErrorMessages()
  23. {
  24. $packageMock = $this->getMock('Composer\Package\PackageInterface');
  25. $packageMock->expects($this->any())
  26. ->method('getDistUrl')
  27. ->will($this->returnValue('file://'.__FILE__))
  28. ;
  29. $io = $this->getMock('Composer\IO\IOInterface');
  30. $downloader = new ZipDownloader($io);
  31. try {
  32. $downloader->download($packageMock, sys_get_temp_dir().'/composer-zip-test');
  33. $this->fail('Download of invalid zip files should throw an exception');
  34. } catch (\UnexpectedValueException $e) {
  35. $this->assertContains('is not a zip archive', $e->getMessage());
  36. }
  37. }
  38. }