comparison core/lib/Drupal/Core/Composer/Composer.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 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
142 file_put_contents($webconfig_file, $lines . "\n"); 142 file_put_contents($webconfig_file, $lines . "\n");
143 } 143 }
144 } 144 }
145 145
146 /** 146 /**
147 * Fires the drupal-phpunit-upgrade script event if necessary.
148 *
149 * @param \Composer\Script\Event $event
150 */
151 public static function upgradePHPUnit(Event $event) {
152 $repository = $event->getComposer()->getRepositoryManager()->getLocalRepository();
153 // This is, essentially, a null constraint. We only care whether the package
154 // is present in the vendor directory yet, but findPackage() requires it.
155 $constraint = new Constraint('>', '');
156 $phpunit_package = $repository->findPackage('phpunit/phpunit', $constraint);
157 if (!$phpunit_package) {
158 // There is nothing to do. The user is probably installing using the
159 // --no-dev flag.
160 return;
161 }
162
163 // If the PHP version is 7.2 or above and PHPUnit is less than version 6
164 // call the drupal-phpunit-upgrade script to upgrade PHPUnit.
165 if (!static::upgradePHPUnitCheck($phpunit_package->getVersion())) {
166 $event->getComposer()
167 ->getEventDispatcher()
168 ->dispatchScript('drupal-phpunit-upgrade');
169 }
170 }
171
172 /**
173 * Determines if PHPUnit needs to be upgraded.
174 *
175 * This method is located in this file because it is possible that it is
176 * called before the autoloader is available.
177 *
178 * @param string $phpunit_version
179 * The PHPUnit version string.
180 *
181 * @return bool
182 * TRUE if the PHPUnit needs to be upgraded, FALSE if not.
183 */
184 public static function upgradePHPUnitCheck($phpunit_version) {
185 return !(version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.2') >= 0 && version_compare($phpunit_version, '6.1') < 0);
186 }
187
188 /**
147 * Remove possibly problematic test files from vendored projects. 189 * Remove possibly problematic test files from vendored projects.
148 * 190 *
149 * @param \Composer\Installer\PackageEvent $event 191 * @param \Composer\Installer\PackageEvent $event
150 * A PackageEvent object to get the configured composer vendor directories 192 * A PackageEvent object to get the configured composer vendor directories
151 * from. 193 * from.