Commit | Line | Data |
---|---|---|
e73a88e6 TO |
1 | <?php |
2 | ||
3 | /** | |
4 | * Class CRM_Core_ComposerConfigTest | |
5 | * @group headless | |
6 | */ | |
a6439b6a | 7 | class CRM_Core_ComposerConfigTest extends \PHPUnit\Framework\TestCase { |
e73a88e6 TO |
8 | |
9 | /** | |
10 | * Assert that `composer.lock` remains as expected. | |
11 | * | |
12 | * Intentions: | |
13 | * - In `civicrm-core`, the `composer.json` is permissive. It can be updated | |
14 | * to support different versions of Symfony. | |
15 | * - In `civicrm-core`, the `composer.lock` is less permissive, driven by | |
16 | * the interests of existing D7/WP/J sites. | |
17 | * | |
18 | * Without this check, a well-meaning developer may upgrade the | |
19 | * `composer.lock`, and no one would notice the change in policy | |
20 | * because reviewers' eyes tend to gloss over `composer.lock`. | |
21 | */ | |
22 | public function testHardLocks() { | |
9099cab3 | 23 | $hardLocks = [ |
c2b44ba2 SL |
24 | 'symfony/config' => '/^v3\.4\./', |
25 | 'symfony/dependency-injection' => '/^v3\.4\./', | |
26 | 'symfony/event-dispatcher' => '/^v3\.4\./', | |
27 | 'symfony/filesystem' => '/^v3\.4\./', | |
28 | 'symfony/finder' => '/^v3\.4\./', | |
29 | 'symfony/process' => '/^v3\.4\./', | |
9099cab3 | 30 | ]; |
e73a88e6 TO |
31 | |
32 | $lockFile = Civi::paths()->getPath('[civicrm.root]/composer.lock'); | |
33 | $lock = json_decode(file_get_contents($lockFile), 1); | |
34 | ||
35 | foreach ($lock['packages'] as $package) { | |
36 | if (isset($hardLocks[$package['name']])) { | |
37 | $this->assertRegExp($hardLocks[$package['name']], $package['version'], | |
38 | "Check hardlock for " . $package['name']); | |
39 | unset($hardLocks[$package['name']]); | |
40 | } | |
41 | } | |
9099cab3 | 42 | $this->assertEquals([], $hardLocks, |
e73a88e6 TO |
43 | 'composer.lock should have references to all hardlocks'); |
44 | } | |
45 | ||
46 | } |