allow injecting a mock filesystem into LibraryInstaller and fix LibraryInstallerTest
parent
f82c820a32
commit
c6ec739766
|
@ -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'), '/');
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue