You are here

public function ConfigTest::testMixedCaseConfigCleanupPackages in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\ConfigTest::testMixedCaseConfigCleanupPackages()

@covers ::getAllCleanupPaths

File

core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php, line 89

Class

ConfigTest
@coversDefaultClass Drupal\Composer\Plugin\VendorHardening\Config @group VendorHardening

Namespace

Drupal\Tests\Composer\Plugin\VendorHardening

Code

public function testMixedCaseConfigCleanupPackages() {

  // Root package has configuration in extra.
  $root = $this
    ->getMockBuilder(RootPackageInterface::class)
    ->setMethods([
    'getExtra',
  ])
    ->getMockForAbstractClass();
  $root
    ->expects($this
    ->once())
    ->method('getExtra')
    ->willReturn([
    'drupal-core-vendor-hardening' => [
      'NotMikey179/vfsStream' => [
        'src/test',
      ],
    ],
  ]);
  $config = new Config($root);
  $ref_plugin_config = new \ReflectionMethod($config, 'getAllCleanupPaths');
  $ref_plugin_config
    ->setAccessible(TRUE);

  // Put some mixed-case in the defaults.
  $ref_default = new \ReflectionProperty($config, 'defaultConfig');
  $ref_default
    ->setAccessible(TRUE);
  $ref_default
    ->setValue($config, [
    'BeHatted/Mank' => [
      'tests',
    ],
    'SymFunic/HTTPFoundational' => [
      'src',
    ],
  ]);
  $plugin_config = $ref_plugin_config
    ->invoke($config);
  foreach (array_keys($plugin_config) as $package_name) {
    $this
      ->assertNotRegExp('/[A-Z]/', $package_name);
  }
}