Commit 408f6296 authored by catch's avatar catch
Browse files

Issue #3265546 by Spokje, quietone:...

Issue #3265546 by Spokje, quietone: Drupal\KernelTests\Config\DefaultConfigTest throws deprecation notice for deprecated Core modules/themes which have config
parent d7a82b5b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
deprecated_module.settings:
  type: config_object
  label: 'deprecated_module settings'
  mapping:
    foo:
      type: string
      label: 'Wait until you meet baz!'
+2 −0
Original line number Diff line number Diff line
favicon:
  use_default: true
+3 −0
Original line number Diff line number Diff line
test_deprecated_theme.settings:
  type: theme_settings
  label: 'test_deprecated_theme settings'
+52 −3
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ class DefaultConfigTest extends KernelTestBase {
  /**
   * Tests if installed config is equal to the exported config.
   *
   * @dataProvider coreModuleListDataProvider
   * @dataProvider moduleListDataProvider
   */
  public function testModuleConfig($module) {
    $this->assertExtensionConfig($module, 'module');
@@ -75,6 +75,31 @@ public function testThemeConfig($theme) {
   * @internal
   */
  protected function assertExtensionConfig(string $name, string $type): void {
    // Parse .info.yml file for module/theme $name. Since it's not installed at
    // this point we can't retrieve it from the 'module_handler' service.
    switch ($name) {
      case 'test_deprecated_theme':
        $file_name = DRUPAL_ROOT . '/core/modules/system/tests/themes/' . $name . '/' . $name . '.info.yml';
        break;

      case 'deprecated_module':
        $file_name = DRUPAL_ROOT . '/core/modules/system/tests/modules/' . $name . '/' . $name . '.info.yml';
        break;

      default;
        $file_name = DRUPAL_ROOT . '/core/' . $type . 's/' . $name . '/' . $name . '.info.yml';
    }

    $info = \Drupal::service('info_parser')->parse($file_name);
    // Test we have a parsed info.yml file.
    $this->assertNotEmpty($info);

    // Skip deprecated extensions.
    if (isset($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER])
      && $info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) {
      $this->markTestSkipped("The $type '$name' is deprecated.");
    }

    // System and user are required in order to be able to install some of the
    // other modules. Therefore they are put into static::$modules, which though
    // doesn't install config files, so import those config files explicitly. Do
@@ -114,8 +139,11 @@ protected function assertExtensionConfig(string $name, string $type): void {
  /**
   * A data provider that lists every theme in core.
   *
   * @return array
   *   An array of theme names to test.
   * Also adds a deprecated theme with config.
   *
   * @return string[][]
   *   An array of theme names to test, with both key and value being the name
   *   of the theme.
   */
  public function themeListDataProvider() {
    $prefix = dirname(__DIR__, 4) . DIRECTORY_SEPARATOR . 'themes';
@@ -128,11 +156,32 @@ public function themeListDataProvider() {
    // Engines is not a theme.
    unset($themes_keyed['engines']);

    // Add a deprecated theme with config.
    $themes_keyed['test_deprecated_theme'] = 'test_deprecated_theme';

    return array_map(function ($theme) {
      return [$theme];
    }, $themes_keyed);
  }

  /**
   * A data provider that lists every module in core.
   *
   * Also adds a deprecated module with config.
   *
   * @return string[][]
   *   An array of module names to test, with both key and value being the name
   *   of the module.
   */
  public function moduleListDataProvider() {
    $modules_keyed = $this->coreModuleListDataProvider();

    // Add a deprecated module with config.
    $modules_keyed['deprecated_module'] = ['deprecated_module'];

    return $modules_keyed;
  }

  /**
   * Tests that default config matches the installed config.
   *