Issue #3032686 by longwave, jibran, xjm, alexpott, Berdir, amateescu: Remove references to unused packages in Drupal 9's vendor hardening

merge-requests/2419/head
xjm 2020-05-05 07:53:37 -05:00
parent 0e9339a67a
commit 572e554aa9
3 changed files with 34 additions and 12 deletions

View File

@ -24,7 +24,6 @@ class Config {
'behat/mink-browserkit-driver' => ['tests'],
'behat/mink-goutte-driver' => ['tests'],
'behat/mink-selenium2-driver' => ['tests'],
'brumann/polyfill-unserialize' => ['tests'],
'composer/composer' => ['bin'],
'drupal/coder' => [
'coder_sniffer/Drupal/Test',
@ -37,13 +36,10 @@ class Config {
'guzzlehttp/promises' => ['tests'],
'guzzlehttp/psr7' => ['tests'],
'instaclick/php-webdriver' => ['doc', 'test'],
'jcalderonzumba/gastonjs' => ['docs', 'examples', 'tests'],
'jcalderonzumba/mink-phantomjs-driver' => ['tests'],
'justinrainbow/json-schema' => ['demo'],
'masterminds/html5' => ['bin', 'test'],
'mikey179/vfsstream' => ['src/test'],
'myclabs/deep-copy' => ['doc'],
'paragonie/random_compat' => ['tests'],
'pear/archive_tar' => ['docs', 'tests'],
'pear/console_getopt' => ['tests'],
'pear/pear-core-minimal' => ['tests'],
@ -56,7 +52,6 @@ class Config {
'phpunit/php-timer' => ['tests'],
'phpunit/php-token-stream' => ['tests'],
'phpunit/phpunit' => ['tests'],
'phpunit/phpunit-mock-objects' => ['tests'],
'sebastian/code-unit-reverse-lookup' => ['tests'],
'sebastian/comparator' => ['tests'],
'sebastian/diff' => ['tests'],

View File

@ -20,13 +20,8 @@ class Composer {
'behat/mink-browserkit-driver' => ['tests'],
'behat/mink-goutte-driver' => ['tests'],
'behat/mink-selenium2-driver' => ['tests'],
'brumann/polyfill-unserialize' => ['tests'],
'composer/composer' => ['bin'],
'drupal/coder' => ['coder_sniffer/Drupal/Test', 'coder_sniffer/DrupalPractice/Test'],
'doctrine/cache' => ['tests'],
'doctrine/collections' => ['tests'],
'doctrine/common' => ['tests'],
'doctrine/inflector' => ['tests'],
'doctrine/instantiator' => ['tests'],
'easyrdf/easyrdf' => ['scripts'],
'egulias/email-validator' => ['documentation', 'tests'],
@ -41,7 +36,6 @@ class Composer {
'masterminds/html5' => ['bin', 'test'],
'mikey179/vfsStream' => ['src/test'],
'myclabs/deep-copy' => ['doc'],
'paragonie/random_compat' => ['tests'],
'pear/archive_tar' => ['docs', 'tests'],
'pear/console_getopt' => ['tests'],
'pear/pear-core-minimal' => ['tests'],
@ -54,7 +48,6 @@ class Composer {
'phpunit/php-timer' => ['tests'],
'phpunit/php-token-stream' => ['tests'],
'phpunit/phpunit' => ['tests'],
'phpunit/phpunit-mock-objects' => ['tests'],
'sebastian/code-unit-reverse-lookup' => ['tests'],
'sebastian/comparator' => ['tests'],
'sebastian/diff' => ['tests'],

View File

@ -2,6 +2,8 @@
namespace Drupal\Tests;
use Drupal\Composer\Plugin\VendorHardening\Config;
use Drupal\Core\Composer\Composer;
use Drupal\Tests\Composer\ComposerIntegrationTrait;
use Symfony\Component\Yaml\Yaml;
@ -241,4 +243,36 @@ class ComposerIntegrationTest extends UnitTestCase {
}
// @codingStandardsIgnoreEnd
/**
* Tests the vendor cleanup utilities do not have obsolete packages listed.
*
* @dataProvider providerTestVendorCleanup
*/
public function testVendorCleanup($class, $property) {
$lock = json_decode(file_get_contents($this->root . '/composer.lock'), TRUE);
$packages = [];
foreach (array_merge($lock['packages'], $lock['packages-dev']) as $package) {
$packages[] = $package['name'];
}
$reflection = new \ReflectionProperty($class, $property);
$reflection->setAccessible(TRUE);
$config = $reflection->getValue();
foreach (array_keys($config) as $package) {
$this->assertContains(strtolower($package), $packages);
}
}
/**
* Data provider for the vendor cleanup utility classes.
*
* @return array[]
*/
public function providerTestVendorCleanup() {
return [
[Composer::class, 'packageToCleanup'],
[Config::class, 'defaultConfig'],
];
}
}