Skip to content

Instantly share code, notes, and snippets.

@jibran
Created February 13, 2019 14:16
Show Gist options
  • Save jibran/9839caea02eb7415ecfd21a64d6ad804 to your computer and use it in GitHub Desktop.
Save jibran/9839caea02eb7415ecfd21a64d6ad804 to your computer and use it in GitHub Desktop.
Tests Drupal dependencies are correct.
/**
* Tests Drupal dependencies are correct.
*/
public function testDrupalDependencies() {
$excluded_packages = [
'wikimedia/composer-merge-plugin',
'ircmaxell/password-compat',
];
$project_lock = json_decode(file_get_contents($this->root . '/composer.lock'), TRUE);
// Drupal 8.6.9 lock file.
$core_lock = json_decode(file_get_contents($this->root . '/tests/fixture/composer.lock'), TRUE);
$core_lock_packages = array_merge($core_lock['packages'], $core_lock['packages-dev']);
$project_lock_packages = array_merge($project_lock['packages'], $project_lock['packages-dev']);
foreach ($core_lock_packages as $package) {
if (!in_array($package['name'], $excluded_packages)) {
$key = array_search($package['name'], array_column($project_lock_packages, 'name'));
$this->assertFalse($key === FALSE, sprintf('%s package is missing', $package['name']));
$this->assertSame($package['version'], $project_lock_packages[$key]['version'], sprintf('%s version required for %s package.', $package['version'], $package['name']));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment