You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.2 KiB
PHTML

<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* 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\Downloader\XzDownloader;
use Composer\Util\Filesystem;
9 years ago
use Composer\Util\RemoteFilesystem;
class XzDownloaderTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Filesystem
*/
private $fs;
/**
* @var string
*/
9 years ago
private $testDir;
public function setUp()
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->markTestSkipped('Skip test on Windows');
}
9 years ago
$this->testDir = sys_get_temp_dir().'/composer-xz-test-vendor';
}
public function tearDown()
{
9 years ago
$this->fs = new Filesystem;
9 years ago
$this->fs->removeDirectory($this->testDir);
}
public function testErrorMessages()
{
$packageMock = $this->getMock('Composer\Package\PackageInterface');
$packageMock->expects($this->any())
->method('getDistUrl')
->will($this->returnValue($distUrl = 'file://'.__FILE__))
;
$packageMock->expects($this->any())
->method('getDistUrls')
->will($this->returnValue(array($distUrl)))
;
$packageMock->expects($this->atLeastOnce())
->method('getTransportOptions')
->will($this->returnValue(array()))
;
$io = $this->getMock('Composer\IO\IOInterface');
$config = $this->getMock('Composer\Config');
$config->expects($this->any())
->method('get')
->with('vendor-dir')
9 years ago
->will($this->returnValue($this->testDir));
9 years ago
$downloader = new XzDownloader($io, $config, null, null, null, new RemoteFilesystem($io));
try {
$downloader->download($packageMock, sys_get_temp_dir().'/composer-xz-test');
$this->fail('Download of invalid tarball should throw an exception');
} catch (\RuntimeException $e) {
$this->assertContains('File format not recognized', $e->getMessage());
}
}
}