assertConfigDiff example


  protected function assertDefaultConfig(StorageInterface $default_config_storage, StorageInterface $active_config_storage): void {
    /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
    $config_manager = $this->container->get('config.manager');

    foreach ($default_config_storage->listAll() as $config_name) {
      if ($active_config_storage->exists($config_name)) {
        $result = $config_manager->diff($default_config_storage$active_config_storage$config_name);
        $this->assertConfigDiff($result$config_name[
          // The filter.format.*:roles key is a special install key.           'filter.format.basic_html' => ['roles:', ' - authenticated'],
          'filter.format.full_html' => ['roles:', ' - administrator'],
          'filter.format.restricted_html' => ['roles:', ' - anonymous'],
          // The system.site config is overwritten during tests by           // FunctionalTestSetupTrait::installParameters().           'system.site' => ['uuid:', 'name:', 'mail:'],
        ]);
      }
      else {
        $this->fail("$config_name has not been installed");
      }
->getConfigPrefix());
          $entity_storage->load($id)->calculateDependencies()->save();
        }
        else {
          // Ensure simple configuration is re-saved so any schema sorting is           // applied.           $config_factory->getEditable($config_name)->save();
        }
        $result = $config_manager->diff($default_config_storage$active_config_storage$config_name);
        // ::assertConfigDiff will throw an exception if the configuration is         // different.         $this->assertNull($this->assertConfigDiff($result$config_namestatic::$skippedConfig));
      }
      else {
        $data = $default_config_storage->read($config_name);
        $dependency = new ConfigEntityDependency($config_name$data);
        if ($dependency->hasDependency('module', 'standard')) {
          // Skip configuration with a dependency on the standard profile. Such           // configuration has probably been removed from the standard profile           // and needs its own test.           continue;
        }
        $info = $this->container->get("extension.list.$type")->getExtensionInfo($extension);
        
$this->addToAssertionCount(1);
    /** @var \Drupal\Core\Config\StorageInterface $active_config_storage */
    $active_config_storage = $this->container->get('config.storage');
    /** @var \Drupal\Core\Config\ConfigManagerInterface $config_manager */
    $config_manager = $this->container->get('config.manager');

    $default_install_path = 'core/profiles/' . $this->profile . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
    $profile_config_storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);

    foreach ($profile_config_storage->listAll() as $config_name) {
      $result = $config_manager->diff($profile_config_storage$active_config_storage$config_name);
      $this->assertConfigDiff($result$config_name$skipped_config);
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.