1
0
Fork 0

allow injecting a mock filesystem into LibraryInstaller and fix LibraryInstallerTest

pull/2279/head
Karoly Negyesi 2013-09-20 06:02:36 +02:00
parent f82c820a32
commit c6ec739766
2 changed files with 10 additions and 3 deletions

View File

@ -41,15 +41,16 @@ class LibraryInstaller implements InstallerInterface
* @param IOInterface $io
* @param Composer $composer
* @param string $type
* @param Filesystem $filesystem
*/
public function __construct(IOInterface $io, Composer $composer, $type = 'library')
public function __construct(IOInterface $io, Composer $composer, $type = 'library', $filesystem = NULL)
{
$this->composer = $composer;
$this->downloadManager = $composer->getDownloadManager();
$this->io = $io;
$this->type = $type;
$this->filesystem = new Filesystem();
$this->filesystem = $filesystem ?: new Filesystem();
$this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
$this->binDir = rtrim($composer->getConfig()->get('bin-dir'), '/');
}

View File

@ -131,7 +131,8 @@ class LibraryInstallerTest extends TestCase
*/
public function testUpdate()
{
$library = new LibraryInstaller($this->io, $this->composer);
$filesystem = $this->getMockBuilder('Composer\Util\Filesystem')->getMock();
$library = new LibraryInstaller($this->io, $this->composer, 'library', $filesystem);
$initial = $this->createPackageMock();
$target = $this->createPackageMock();
@ -140,6 +141,11 @@ class LibraryInstallerTest extends TestCase
->method('getPrettyName')
->will($this->returnValue('package1'));
$target
->expects($this->once())
->method('getPrettyName')
->will($this->returnValue('package1'));
$this->repository
->expects($this->exactly(3))
->method('hasPackage')