comparison core/tests/Drupal/Tests/ComposerIntegrationTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children af1871eacc83
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php 1 <?php
2 2
3 namespace Drupal\Tests; 3 namespace Drupal\Tests;
4
5 use Composer\Semver\Semver;
4 6
5 /** 7 /**
6 * Tests Composer integration. 8 * Tests Composer integration.
7 * 9 *
8 * @group Composer 10 * @group Composer
9 */ 11 */
10 class ComposerIntegrationTest extends UnitTestCase { 12 class ComposerIntegrationTest extends UnitTestCase {
13
14 /**
15 * The minimum PHP version supported by Drupal.
16 *
17 * @see https://www.drupal.org/docs/8/system-requirements/web-server
18 *
19 * @todo Remove as part of https://www.drupal.org/node/2908079
20 */
21 const MIN_PHP_VERSION = '5.5.9';
11 22
12 /** 23 /**
13 * Gets human-readable JSON error messages. 24 * Gets human-readable JSON error messages.
14 * 25 *
15 * @return string[] 26 * @return string[]
169 'Unable to find ' . $module_name . ' in replace list of composer.json' 180 'Unable to find ' . $module_name . ' in replace list of composer.json'
170 ); 181 );
171 } 182 }
172 } 183 }
173 184
185 /**
186 * Tests package requirements for the minimum supported PHP version by Drupal.
187 *
188 * @todo This can be removed when DrupalCI supports dependency regression
189 * testing in https://www.drupal.org/node/2874198
190 */
191 public function testMinPHPVersion() {
192 // Check for lockfile in the application root. If the lockfile does not
193 // exist, then skip this test.
194 $lockfile = $this->root . '/composer.lock';
195 if (!file_exists($lockfile)) {
196 $this->markTestSkipped('/composer.lock is not available.');
197 }
198
199 $lock = json_decode(file_get_contents($lockfile), TRUE);
200
201 // Check the PHP version for each installed non-development package. The
202 // testing infrastructure uses the uses the development packages, and may
203 // update them for particular environment configurations. In particular,
204 // PHP 7.2+ require an updated version of phpunit, which is incompatible
205 // with Drupal's minimum PHP requirement.
206 foreach ($lock['packages'] as $package) {
207 if (isset($package['require']['php'])) {
208 $this->assertTrue(Semver::satisfies(static::MIN_PHP_VERSION, $package['require']['php']), $package['name'] . ' has a PHP dependency requirement of "' . $package['require']['php'] . '"');
209 }
210 }
211 }
212
174 // @codingStandardsIgnoreStart 213 // @codingStandardsIgnoreStart
175 /** 214 /**
176 * The following method is copied from \Composer\Package\Locker. 215 * The following method is copied from \Composer\Package\Locker.
177 * 216 *
178 * @see https://github.com/composer/composer 217 * @see https://github.com/composer/composer