diff --git a/tests/Composer/Test/Fixtures/installer/install-without-lock.test b/tests/Composer/Test/Fixtures/installer/install-without-lock.test new file mode 100644 index 000000000..c5d73dcbb --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/install-without-lock.test @@ -0,0 +1,25 @@ +--TEST-- +Installs from composer.json without writing a lock file +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { "name": "a/a", "version": "1.0.0" } + ] + } + ], + "require": { + "a/a": "1.0.0" + }, + "config": { + "lock": "false" + } +} +--RUN-- +install +--EXPECT-- +Installing a/a (1.0.0) +--EXPECT-LOCK-- +false diff --git a/tests/Composer/Test/Fixtures/installer/update-without-lock.test b/tests/Composer/Test/Fixtures/installer/update-without-lock.test new file mode 100644 index 000000000..0fd1562c3 --- /dev/null +++ b/tests/Composer/Test/Fixtures/installer/update-without-lock.test @@ -0,0 +1,25 @@ +--TEST-- +Updates when no lock file is present without writing a lock file +--COMPOSER-- +{ + "repositories": [ + { + "type": "package", + "package": [ + { "name": "a/a", "version": "1.0.0" } + ] + } + ], + "require": { + "a/a": "1.0.0" + }, + "config": { + "lock": false + } +} +--RUN-- +update +--EXPECT-- +Installing a/a (1.0.0) +--EXPECT-LOCK-- +false diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index c3b957afb..fa093a460 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -197,6 +197,9 @@ class InstallerTest extends TestCase // so store value temporarily in reference for later assetion $actualLock = $hash; })); + } elseif ($expectLock === false) { + $lockJsonMock->expects($this->never()) + ->method('write'); } $contents = json_encode($composerConfig); @@ -319,7 +322,11 @@ class InstallerTest extends TestCase } $run = $testData['RUN']; if (!empty($testData['EXPECT-LOCK'])) { - $expectLock = JsonFile::parseJson($testData['EXPECT-LOCK']); + if ($testData['EXPECT-LOCK'] === 'false') { + $expectLock = false; + } else { + $expectLock = JsonFile::parseJson($testData['EXPECT-LOCK']); + } } $expectOutput = isset($testData['EXPECT-OUTPUT']) ? $testData['EXPECT-OUTPUT'] : null; $expect = $testData['EXPECT'];