Skip to content

Commit 2e8383d

Browse files
MAGETWO-69539: PHP "soap" extension is not declared in composer.json but can be used by Magento modules
- Fixed conflict composer.lock
2 parents ee31fd1 + 33fc68d commit 2e8383d

File tree

3 files changed

+116
-8
lines changed

3 files changed

+116
-8
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"ext-openssl": "*",
6969
"ext-zip": "*",
7070
"ext-pdo_mysql": "*",
71+
"ext-soap": "*",
7172
"sjparkinson/static-review": "~4.1",
7273
"ramsey/uuid": "3.6.1"
7374
},

composer.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/static/testsuite/Magento/Test/Integrity/ComposerLockTest.php

Lines changed: 113 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,121 @@
1010
*/
1111
class ComposerLockTest extends \PHPUnit_Framework_TestCase
1212
{
13-
public function testUpToDate()
13+
/**
14+
* @return string
15+
*/
16+
public function testLockFileExists()
1417
{
15-
$hash = hash_file('md5', BP . '/composer.json');
1618
$lockFilePath = BP . '/composer.lock';
17-
if (!file_exists($lockFilePath)) {
18-
$this->markTestSkipped('composer.lock file doesn\'t exist');
19+
$this->assertLockFileExists($lockFilePath);
20+
return $lockFilePath;
21+
}
22+
23+
/**
24+
* @depends testLockFileExists
25+
* @param string $lockFilePath
26+
* @return string
27+
*/
28+
public function testLockFileReadable($lockFilePath)
29+
{
30+
$this->assertLockFileReadable($lockFilePath);
31+
return $lockFilePath;
32+
}
33+
34+
/**
35+
* @depends testLockFileReadable
36+
* @param string $lockFilePath
37+
* @return string
38+
*/
39+
public function testLockFileContainsJson($lockFilePath)
40+
{
41+
$lockFileContent = file_get_contents($lockFilePath);
42+
$this->assertLockFileContainsValidJson($lockFileContent);
43+
return $lockFileContent;
44+
}
45+
46+
/**
47+
* @depends testLockFileContainsJson
48+
* @param string $lockFileContent
49+
*/
50+
public function testUpToDate($lockFileContent)
51+
{
52+
$lockData = json_decode($lockFileContent, true);
53+
$composerFilePath = BP . '/composer.json';
54+
$this->assertLockDataRelevantToComposerFile($lockData, $composerFilePath);
55+
}
56+
57+
/**
58+
* @param string $lockFilePath
59+
*/
60+
private function assertLockFileExists($lockFilePath)
61+
{
62+
$this->assertFileExists($lockFilePath, 'composer.lock file does not exist');
63+
}
64+
65+
/**
66+
* @param string $lockFilePath
67+
*/
68+
private function assertLockFileReadable($lockFilePath)
69+
{
70+
if (!is_readable($lockFilePath)) {
71+
$this->fail('composer.lock file is not readable');
1972
}
20-
$jsonData = file_get_contents($lockFilePath);
21-
$json = json_decode($jsonData);
22-
$this->assertSame($hash, $json->hash, 'composer.lock file is not up to date');
73+
}
74+
75+
/**
76+
* @param string $lockFileContent
77+
*/
78+
private function assertLockFileContainsValidJson($lockFileContent)
79+
{
80+
$this->assertJson($lockFileContent, 'composer.lock file does not contains valid json');
81+
}
82+
83+
/**
84+
* @param array $lockData
85+
* @param string $composerFilePath
86+
*/
87+
private function assertLockDataRelevantToComposerFile(array $lockData, $composerFilePath)
88+
{
89+
if (isset($lockData['content-hash'])) {
90+
$this->assertLockDataRelevantToMeaningfulComposerConfig($lockData, $composerFilePath);
91+
} else if (isset($lockData['hash'])) {
92+
$this->assertLockDataRelevantToFullComposerConfig($lockData, $composerFilePath);
93+
} else {
94+
$this->fail('composer.lock does not linked to composer.json data');
95+
}
96+
}
97+
98+
/**
99+
* @param array $lockData
100+
* @param string $composerFilePath
101+
*/
102+
private function assertLockDataRelevantToMeaningfulComposerConfig(array $lockData, $composerFilePath)
103+
{
104+
$contentHashCalculator = 'Composer\Package\Locker::getContentHash';
105+
if (!is_callable($contentHashCalculator)) {
106+
$this->markTestSkipped('Unable to check composer.lock file by content hash');
107+
}
108+
109+
$composerContentHash = call_user_func($contentHashCalculator, file_get_contents($composerFilePath));
110+
$this->assertSame(
111+
$composerContentHash,
112+
$lockData['content-hash'],
113+
'composer.lock file is not up to date (composer.json file was modified)'
114+
);
115+
}
116+
117+
/**
118+
* @param array $lockData
119+
* @param string $composerFilePath
120+
*/
121+
private function assertLockDataRelevantToFullComposerConfig(array $lockData, $composerFilePath)
122+
{
123+
$composerFileHash = hash_file('md5', $composerFilePath);
124+
$this->assertSame(
125+
$composerFileHash,
126+
$lockData['hash'],
127+
'composer.lock file is not up to date (composer.json file was modified)'
128+
);
23129
}
24130
}

0 commit comments

Comments
 (0)