From 6059acf0a39fa97147fa8c26de95b4aa8ea1bcc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Wed, 27 Dec 2017 13:20:12 +0100 Subject: [PATCH] Fix: Remove unused parameter and field --- src/Composer/Factory.php | 2 +- src/Composer/Package/Locker.php | 5 +-- tests/Composer/Test/InstallerTest.php | 2 +- tests/Composer/Test/Package/LockerTest.php | 44 ++++++---------------- 4 files changed, 14 insertions(+), 39 deletions(-) diff --git a/src/Composer/Factory.php b/src/Composer/Factory.php index a68586fbb..e1c4cf95c 100644 --- a/src/Composer/Factory.php +++ b/src/Composer/Factory.php @@ -390,7 +390,7 @@ class Factory ? substr($composerFile, 0, -4).'lock' : $composerFile . '.lock'; - $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $rm, $im, file_get_contents($composerFile)); + $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile)); $composer->setLocker($locker); } diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 93e5ca655..e86115bfb 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -32,7 +32,6 @@ use Seld\JsonLint\ParsingException; class Locker { private $lockFile; - private $repositoryManager; private $installationManager; private $hash; private $contentHash; @@ -46,14 +45,12 @@ class Locker * * @param IOInterface $io * @param JsonFile $lockFile lockfile loader - * @param RepositoryManager $repositoryManager repository manager instance * @param InstallationManager $installationManager installation manager instance * @param string $composerFileContents The contents of the composer file */ - public function __construct(IOInterface $io, JsonFile $lockFile, RepositoryManager $repositoryManager, InstallationManager $installationManager, $composerFileContents) + public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, $composerFileContents) { $this->lockFile = $lockFile; - $this->repositoryManager = $repositoryManager; $this->installationManager = $installationManager; $this->hash = md5($composerFileContents); $this->contentHash = self::getContentHash($composerFileContents); diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 468d8fbbd..fe17f2959 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -198,7 +198,7 @@ class InstallerTest extends TestCase } $contents = json_encode($composerConfig); - $locker = new Locker($io, $lockJsonMock, $repositoryManager, $composer->getInstallationManager(), $contents); + $locker = new Locker($io, $lockJsonMock, $composer->getInstallationManager(), $contents); $composer->setLocker($locker); $eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock(); diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php index a37e09907..63fbf4a1b 100644 --- a/tests/Composer/Test/Package/LockerTest.php +++ b/tests/Composer/Test/Package/LockerTest.php @@ -21,7 +21,7 @@ class LockerTest extends TestCase public function testIsLocked() { $json = $this->createJsonFileMock(); - $locker = new Locker(new NullIO, $json, $this->createRepositoryManagerMock(), $this->createInstallationManagerMock(), + $locker = new Locker(new NullIO, $json, $this->createInstallationManagerMock(), $this->getJsonContent()); $json @@ -39,10 +39,9 @@ class LockerTest extends TestCase public function testGetNotLockedPackages() { $json = $this->createJsonFileMock(); - $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker(new NullIO, $json, $repo, $inst, $this->getJsonContent()); + $locker = new Locker(new NullIO, $json, $inst, $this->getJsonContent()); $json ->expects($this->once()) @@ -57,10 +56,9 @@ class LockerTest extends TestCase public function testGetLockedPackages() { $json = $this->createJsonFileMock(); - $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker(new NullIO, $json, $repo, $inst, $this->getJsonContent()); + $locker = new Locker(new NullIO, $json, $inst, $this->getJsonContent()); $json ->expects($this->once()) @@ -84,11 +82,10 @@ class LockerTest extends TestCase public function testSetLockData() { $json = $this->createJsonFileMock(); - $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); $jsonContent = $this->getJsonContent() . ' '; - $locker = new Locker(new NullIO, $json, $repo, $inst, $jsonContent); + $locker = new Locker(new NullIO, $json, $inst, $jsonContent); $package1 = $this->createPackageMock(); $package2 = $this->createPackageMock(); @@ -157,10 +154,9 @@ class LockerTest extends TestCase public function testLockBadPackages() { $json = $this->createJsonFileMock(); - $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker(new NullIO, $json, $repo, $inst, $this->getJsonContent()); + $locker = new Locker(new NullIO, $json, $inst, $this->getJsonContent()); $package1 = $this->createPackageMock(); $package1 @@ -176,11 +172,10 @@ class LockerTest extends TestCase public function testIsFresh() { $json = $this->createJsonFileMock(); - $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); $jsonContent = $this->getJsonContent(); - $locker = new Locker(new NullIO, $json, $repo, $inst, $jsonContent); + $locker = new Locker(new NullIO, $json, $inst, $jsonContent); $json ->expects($this->once()) @@ -193,10 +188,9 @@ class LockerTest extends TestCase public function testIsFreshFalse() { $json = $this->createJsonFileMock(); - $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker(new NullIO, $json, $repo, $inst, $this->getJsonContent()); + $locker = new Locker(new NullIO, $json, $inst, $this->getJsonContent()); $json ->expects($this->once()) @@ -209,11 +203,10 @@ class LockerTest extends TestCase public function testIsFreshWithContentHash() { $json = $this->createJsonFileMock(); - $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); $jsonContent = $this->getJsonContent(); - $locker = new Locker(new NullIO, $json, $repo, $inst, $jsonContent); + $locker = new Locker(new NullIO, $json, $inst, $jsonContent); $json ->expects($this->once()) @@ -226,11 +219,10 @@ class LockerTest extends TestCase public function testIsFreshWithContentHashAndNoHash() { $json = $this->createJsonFileMock(); - $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); $jsonContent = $this->getJsonContent(); - $locker = new Locker(new NullIO, $json, $repo, $inst, $jsonContent); + $locker = new Locker(new NullIO, $json, $inst, $jsonContent); $json ->expects($this->once()) @@ -243,10 +235,9 @@ class LockerTest extends TestCase public function testIsFreshFalseWithContentHash() { $json = $this->createJsonFileMock(); - $repo = $this->createRepositoryManagerMock(); $inst = $this->createInstallationManagerMock(); - $locker = new Locker(new NullIO, $json, $repo, $inst, $this->getJsonContent()); + $locker = new Locker(new NullIO, $json, $inst, $this->getJsonContent()); $differentHash = md5($this->getJsonContent(array('name' => 'test2'))); @@ -264,20 +255,7 @@ class LockerTest extends TestCase ->disableOriginalConstructor() ->getMock(); } - - private function createRepositoryManagerMock() - { - $mock = $this->getMockBuilder('Composer\Repository\RepositoryManager') - ->disableOriginalConstructor() - ->getMock(); - - $mock->expects($this->any()) - ->method('getLocalRepository') - ->will($this->returnValue($this->getMockBuilder('Composer\Repository\ArrayRepository')->getMock())); - - return $mock; - } - + private function createInstallationManagerMock() { $mock = $this->getMockBuilder('Composer\Installer\InstallationManager')