1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 17:12:51 +00:00

Update Git/Hg downloaders tests, making sure they never use a live filesystem instance

This commit is contained in:
Jordi Boggiano 2012-03-08 00:11:52 +01:00
parent 775c00258d
commit ada9c20db1
4 changed files with 75 additions and 29 deletions

View file

@ -16,6 +16,15 @@ use Composer\Downloader\HgDownloader;
class HgDownloaderTest extends \PHPUnit_Framework_TestCase
{
protected function getDownloaderMock($io = null, $executor = null, $filesystem = null)
{
$io = $io ?: $this->getMock('Composer\IO\IOInterface');
$executor = $executor ?: $this->getMock('Composer\Util\ProcessExecutor');
$filesystem = $filesystem ?: $this->getMock('Composer\Util\Filesystem');
return new HgDownloader($io, $executor, $filesystem);
}
/**
* @expectedException \InvalidArgumentException
*/
@ -26,7 +35,7 @@ class HgDownloaderTest extends \PHPUnit_Framework_TestCase
->method('getSourceReference')
->will($this->returnValue(null));
$downloader = new HgDownloader($this->getMock('Composer\IO\IOInterface'));
$downloader = $this->getDownloaderMock();
$downloader->download($packageMock, '/path');
}
@ -45,7 +54,7 @@ class HgDownloaderTest extends \PHPUnit_Framework_TestCase
->method('execute')
->with($this->equalTo($expectedGitCommand));
$downloader = new HgDownloader($this->getMock('Composer\IO\IOInterface'), $processExecutor);
$downloader = $this->getDownloaderMock(null, $processExecutor);
$downloader->download($packageMock, 'composerPath');
}
@ -60,7 +69,7 @@ class HgDownloaderTest extends \PHPUnit_Framework_TestCase
->method('getSourceReference')
->will($this->returnValue(null));
$downloader = new HgDownloader($this->getMock('Composer\IO\IOInterface'));
$downloader = $this->getDownloaderMock();
$downloader->update($initialPackageMock, $sourcePackageMock, '/path');
}
@ -84,7 +93,7 @@ class HgDownloaderTest extends \PHPUnit_Framework_TestCase
->method('execute')
->with($this->equalTo($expectedUpdateCommand));
$downloader = new HgDownloader($this->getMock('Composer\IO\IOInterface'), $processExecutor);
$downloader = $this->getDownloaderMock(null, $processExecutor);
$downloader->update($packageMock, $packageMock, 'composerPath');
}
@ -102,13 +111,13 @@ class HgDownloaderTest extends \PHPUnit_Framework_TestCase
->method('removeDirectory')
->with($this->equalTo('composerPath'));
$downloader = new HgDownloader($this->getMock('Composer\IO\IOInterface'), $processExecutor, $filesystem);
$downloader = $this->getDownloaderMock(null, $processExecutor, $filesystem);
$downloader->remove($packageMock, 'composerPath');
}
public function testGetInstallationSource()
{
$downloader = new HgDownloader($this->getMock('Composer\IO\IOInterface'));
$downloader = $this->getDownloaderMock(null);
$this->assertEquals('source', $downloader->getInstallationSource());
}