18 $lockFilePath =
BP .
'/composer.lock';
19 $this->assertLockFileExists($lockFilePath);
30 $this->assertLockFileReadable($lockFilePath);
42 $this->assertLockFileContainsValidJson($lockFileContent);
43 return $lockFileContent;
52 $lockData = json_decode($lockFileContent,
true);
53 $composerFilePath =
BP .
'/composer.json';
54 $this->assertLockDataRelevantToComposerFile($lockData, $composerFilePath);
60 private function assertLockFileExists($lockFilePath)
62 $this->assertFileExists($lockFilePath,
'composer.lock file does not exist');
68 private function assertLockFileReadable($lockFilePath)
71 $this->fail(
'composer.lock file is not readable');
78 private function assertLockFileContainsValidJson($lockFileContent)
80 $this->assertJson($lockFileContent,
'composer.lock file does not contains valid json');
87 private function assertLockDataRelevantToComposerFile(array $lockData, $composerFilePath)
89 if (isset($lockData[
'content-hash'])) {
90 $this->assertLockDataRelevantToMeaningfulComposerConfig($lockData, $composerFilePath);
91 }
else if (isset($lockData[
'hash'])) {
92 $this->assertLockDataRelevantToFullComposerConfig($lockData, $composerFilePath);
94 $this->fail(
'composer.lock does not linked to composer.json data');
102 private function assertLockDataRelevantToMeaningfulComposerConfig(array $lockData, $composerFilePath)
104 $contentHashCalculator =
'Composer\Package\Locker::getContentHash';
105 if (!is_callable($contentHashCalculator)) {
106 $this->markTestSkipped(
'Unable to check composer.lock file by content hash');
111 $composerContentHash,
112 $lockData[
'content-hash'],
113 'composer.lock file is not up to date (composer.json file was modified)' 121 private function assertLockDataRelevantToFullComposerConfig(array $lockData, $composerFilePath)
123 $composerFileHash = hash_file(
'md5', $composerFilePath);
127 'composer.lock file is not up to date (composer.json file was modified)' testLockFileContainsJson($lockFilePath)
call_user_func($callable, $param)
testLockFileReadable($lockFilePath)
testUpToDate($lockFileContent)