Merge pull request #14662 from eileenmcnaughton/activity_pdf_71
[civicrm-core.git] / tests / phpunit / CRM / Core / ComposerConfigTest.php
CommitLineData
e73a88e6
TO
1<?php
2
3/**
4 * Class CRM_Core_ComposerConfigTest
5 * @group headless
6 */
a6439b6a 7class 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 = [
5ff57db4
SL
24 'symfony/config' => '/^v2\.8\./',
25 'symfony/dependency-injection' => '/^v2\.8\./',
26 'symfony/event-dispatcher' => '/^v2\.8\./',
27 'symfony/filesystem' => '/^v2\.8\./',
28 'symfony/finder' => '/^v2\.8\./',
29 'symfony/process' => '/^v2\.8\./',
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}