function DemoUmamiProfileTest::testConfig

Same name in other branches
  1. 9 core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php \Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest::testConfig()
  2. 8.9.x core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php \Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest::testConfig()
  3. 11.x core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php \Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest::testConfig()

Tests the profile supplied configuration is the same after installation.

1 call to DemoUmamiProfileTest::testConfig()
DemoUmamiProfileTest::testDemoFeatures in core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php
Tests various capabilities of the demo profile.

File

core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php, line 72

Class

DemoUmamiProfileTest
Tests demo_umami profile.

Namespace

Drupal\Tests\demo_umami\Functional

Code

protected function testConfig() : void {
    // Just connect directly to the config table so we don't need to worry about
    // the cache layer.
    $active_config_storage = $this->container
        ->get('config.storage');
    $default_config_storage = new FileStorage($this->container
        ->get('extension.list.profile')
        ->getPath('demo_umami') . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY, InstallStorage::DEFAULT_COLLECTION);
    $this->assertDefaultConfig($default_config_storage, $active_config_storage);
    $default_config_storage = new FileStorage($this->container
        ->get('extension.list.profile')
        ->getPath('demo_umami') . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY, InstallStorage::DEFAULT_COLLECTION);
    $this->assertDefaultConfig($default_config_storage, $active_config_storage);
    // Now we have all configuration imported, test all of them for schema
    // conformance. Ensures all imported default configuration is valid when
    // Demo Umami profile modules are enabled.
    $names = $this->container
        ->get('config.storage')
        ->listAll();
    
    /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
    $typed_config = $this->container
        ->get('config.typed');
    foreach ($names as $name) {
        $config = $this->config($name);
        $this->assertConfigSchema($typed_config, $name, $config->get());
    }
    // Validate all configuration.
    // @todo Generalize in https://www.drupal.org/project/drupal/issues/2164373
    foreach (Editor::loadMultiple() as $editor) {
        // Currently only text editors using CKEditor 5 can be validated.
        if ($editor->getEditor() !== 'ckeditor5') {
            continue;
        }
        $this->assertSame([], array_map(function (ConstraintViolation $v) {
            return (string) $v->getMessage();
        }, iterator_to_array(CKEditor5::validatePair($editor, $editor->getFilterFormat()))));
    }
}

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