diff --git a/tests/Composer/Test/Downloader/ZipDownloaderTest.php b/tests/Composer/Test/Downloader/ZipDownloaderTest.php new file mode 100644 index 000000000..c0fd6deac --- /dev/null +++ b/tests/Composer/Test/Downloader/ZipDownloaderTest.php @@ -0,0 +1,45 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Test\Downloader; + +use Composer\Util\Filesystem; +use Composer\Downloader\ZipDownloader; + +class ZipDownloaderTest extends \PHPUnit_Framework_TestCase +{ + public function setUp() + { + if (!class_exists('ZipArchive')) { + $this->markTestSkipped('zip extension missing'); + } + } + + public function testErrorMessages() + { + $packageMock = $this->getMock('Composer\Package\PackageInterface'); + $packageMock->expects($this->any()) + ->method('getDistUrl') + ->will($this->returnValue('file://'.__FILE__)) + ; + + $io = $this->getMock('Composer\IO\IOInterface'); + $downloader = new ZipDownloader($io); + + try { + $downloader->download($packageMock, sys_get_temp_dir().'/composer-zip-test'); + $this->fail('Download of invalid zip files should throw an exception'); + } catch (\UnexpectedValueException $e) { + $this->assertContains('is not a zip archive', $e->getMessage()); + } + } +}