function ComposerIntegrationTest::testVendorCleanup

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testVendorCleanup()
  2. 11.x core/tests/Drupal/Tests/ComposerIntegrationTest.php \Drupal\Tests\ComposerIntegrationTest::testVendorCleanup()

Tests the vendor cleanup utilities do not have obsolete packages listed.

@dataProvider providerTestVendorCleanup

File

core/tests/Drupal/Tests/ComposerIntegrationTest.php, line 259

Class

ComposerIntegrationTest
Tests Composer integration.

Namespace

Drupal\Tests

Code

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();
  // PHPUnit 9.5.3 removes 'phpunit/php-token-stream' from its dependencies.
  // @todo remove the check below when PHPUnit 9 is the minimum.
  if (RunnerVersion::getMajor() >= 9) {
    unset($config['phpunit/php-token-stream']);
  }
  foreach (array_keys($config) as $package) {
    $this->assertContains(strtolower($package), $packages);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.