You are here

ConfigTest.php in Style Switcher 8.2

Same filename in this branch
  1. 8.2 tests/src/Functional/ConfigTest.php
  2. 8.2 tests/src/Kernel/ConfigTest.php
Same filename and directory in other branches
  1. 3.0.x tests/src/Kernel/ConfigTest.php

File

tests/src/Kernel/ConfigTest.php
View source
<?php

namespace Drupal\Tests\styleswitcher\Kernel;

use Drupal\KernelTests\KernelTestBase;

/**
 * Tests Style Switcher configs.
 *
 * @group styleswitcher
 */
class ConfigTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'styleswitcher',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this
      ->installConfig(static::$modules);
  }

  /**
   * Tests that corresponding configs are deleted when themes are uninstalled.
   */
  public function testThemesUninstalled() {
    $theme_installer = \Drupal::service('theme_installer');

    // Install a theme and create some styles settings.
    $theme_installer
      ->install([
      'styleswitcher_test_theme',
    ]);
    $this
      ->config('styleswitcher.styles_settings')
      ->set('settings.styleswitcher_test_theme', [
      'style' => [],
    ])
      ->save();

    // Uninstall a theme.
    $theme_installer
      ->uninstall([
      'styleswitcher_test_theme',
    ]);
    $this
      ->assertArrayNotHasKey('styleswitcher_test_theme', $this
      ->config('styleswitcher.styles_settings')
      ->get('settings'));
  }

}

Classes

Namesort descending Description
ConfigTest Tests Style Switcher configs.