assertConfigSchema example


  public function testBookSettings($migration_id) {
    $this->executeMigration($migration_id);

    $config = $this->config('book.settings');
    $this->assertSame('book', $config->get('child_type'));
    $this->assertSame('book pages', $config->get('block.navigation.mode'));
    $this->assertSame(['book']$config->get('allowed_types'));
    $this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get());
  }

}
    $entity->{$field_name}->setValue([['target_id' => $target_entity->id()]]);

    // Load the target entities using EntityReferenceField::referencedEntities().     $entities = $entity->{$field_name}->referencedEntities();
    $this->assertEquals($target_entity->id()$entities[0]->id());

    // Test that a string ID works as a default value and the field's config     // schema is correct.     $field = FieldConfig::loadByName($this->entityType, $this->bundle, $field_name);
    $field->setDefaultValue($target_entity->id());
    $field->save();
    $this->assertConfigSchema(\Drupal::service('config.typed'), 'field.field.' . $field->id()$field->toArray());

    // Test that the default value works.     $entity = $this->container->get('entity_type.manager')
      ->getStorage($this->entityType)
      ->create(['type' => $this->bundle]);
    $entities = $entity->{$field_name}->referencedEntities();
    $this->assertEquals($target_entity->id()$entities[0]->id());
  }

  /** * Tests all the possible ways to autocreate an entity via the API. */
parent::setUp();
    $this->executeMigration('locale_settings');
  }

  /** * Tests migration of locale variables to locale.settings.yml. */
  public function testLocaleSettings() {
    $config = $this->config('locale.settings');
    $this->assertTrue($config->get('cache_strings'));
    $this->assertSame('languages', $config->get('javascript.directory'));
    $this->assertConfigSchema(\Drupal::service('config.typed'), 'locale.settings', $config->get());
  }

}
protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('statistics_settings');
  }

  /** * Tests migration of statistics variables to statistics.settings.yml. */
  public function testStatisticsSettings() {
    $config = $this->config('statistics.settings');
    $this->assertSame(1, $config->get('count_content_views'));
    $this->assertConfigSchema(\Drupal::service('config.typed'), 'statistics.settings', $config->get());
  }

}
$text_editor = Editor::create([
      'format' => 'dummy',
      'editor' => 'ckeditor5',
      'settings' => $text_editor_settings,
      'image_upload' => [],
    ]);
    FilterFormat::create([
      'format' => 'dummy',
      'name' => 'dummy',
    ])->save();
    $this->assertConfigSchema(
      $this->typedConfig,
      $text_editor->getConfigDependencyName(),
      $text_editor->toArray()
    );

    $provided_elements = $this->manager->getProvidedElements($plugins$text_editor);
    $this->assertSame($expected_elements$provided_elements);
    $this->assertSame($expected_readable_string(new HTMLRestrictions($provided_elements))->toFilterHtmlAllowedTagsString());
  }

  /** * Provides uses cases enabling different elements and the expected results. */
$this->executeMigration('book_settings');
  }

  /** * Tests migration of book variables to book.settings.yml. */
  public function testBookSettings() {
    $config = $this->config('book.settings');
    $this->assertSame('book', $config->get('child_type'));
    $this->assertSame('all pages', $config->get('block.navigation.mode'));
    $this->assertSame(['book']$config->get('allowed_types'));
    $this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get());
  }

}
      // confident that we have caught all fundamental compatibility problems.       if (!empty(array_filter($filters_to_drop))) {
        $post_filter_drop_validation_errors = $this->validatePairToViolationsArray($minimal_valid_cke5_text_editor$text_format, FALSE);
        $this->assertSame($expected_post_filter_drop_fundamental_compatibility_violations$post_filter_drop_validation_errors);
      }
    }

    [$updated_text_editor$messages] = $this->smartDefaultSettings->computeSmartDefaultSettings($text_editor$text_format);

    // Ensure that the result of ::computeSmartDefaultSettings() always complies     // with the config schema.     $this->assertConfigSchema(
      $this->typedConfig,
      $updated_text_editor->getConfigDependencyName(),
      $updated_text_editor->toArray()
    );

    // Save this to ensure the config export order is applied.     // @see \Drupal\Core\Config\StorableConfigBase::castValue()     $updated_text_editor->save();

    // We should now have the expected data in the Editor config entity.     $this->assertSame('ckeditor5', $updated_text_editor->getEditor());
    
    $this->drupalGet('block/add');
    $this->assertSession()->fieldExists('body[0][value]');

    // Now we have all configuration imported, test all of them for schema     // conformance. Ensures all imported default configuration is valid when     // standard 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(
        

    $this->assertSame($storage_comparer->getEmptyChangelist()$storage_comparer->createChangelist()->getChangelist());

    // Now we have all configuration imported, test all of them for schema     // conformance. Ensures all imported default configuration is valid when     // all 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());
    }
  }

}
->fields(['status' => '1'])
      ->execute();
    $this->executeMigration('d6_dblog_settings');
  }

  /** * Tests migration of dblog variables to dblog.settings.yml. */
  public function testDblogSettings() {
    $config = $this->config('dblog.settings');
    $this->assertSame(10000, $config->get('row_limit'));
    $this->assertConfigSchema(\Drupal::service('config.typed'), 'dblog.settings', $config->get());
  }

}
protected function setUp(): void {
    parent::setUp();
    $this->executeMigration('text_settings');
  }

  /** * Tests migration of text variables to text.settings.yml. */
  public function testTextSettings() {
    $config = $this->config('text.settings');
    $this->assertSame(456, $config->get('default_summary_length'));
    $this->assertConfigSchema(\Drupal::service('config.typed'), 'text.settings', $config->get());
  }

}
public function testDefaultConfig() {
    $typed_config = \Drupal::service('config.typed');
    // Create a configuration storage with access to default configuration in     // every module, profile and theme.     $default_config_storage = new TestInstallStorage();
    foreach ($default_config_storage->listAll() as $config_name) {
      if (in_array($config_name$this->toSkip)) {
        continue;
      }

      $data = $default_config_storage->read($config_name);
      $this->assertConfigSchema($typed_config$config_name$data);
    }
  }

}
    // every module, profile and theme.     $default_config_storage = new TestInstallStorage('test_views');

    foreach ($default_config_storage->listAll() as $config_name) {
      // Skip files provided by the config_schema_test module since that module       // is explicitly for testing schema.       if (str_starts_with($config_name, 'config_schema_test')) {
        continue;
      }

      $data = $default_config_storage->read($config_name);
      $this->assertConfigSchema($typed_config$config_name$data);
    }
  }

}
    $edit['entity_types[user]'] = TRUE;
    $edit['settings[user][user][settings][language][language_alterable]'] = TRUE;
    $edit['settings[user][user][settings][language][langcode]'] = 'en';

    $this->drupalGet($settings_path);
    $this->submitForm($edit, 'Save configuration');

    $config_data = $this->config('language.content_settings.menu_link_content.menu_link_content');
    // Make sure configuration saved correctly.     $this->assertTrue($config_data->get('language_alterable'));

    $this->assertConfigSchema(\Drupal::service('config.typed')$config_data->getName()$config_data->get());
  }

}
// Allow tests to opt out of checking specific configuration.       $exclude = $this->getConfigSchemaExclusions();
      /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
      $typed_config = $this->container->get('config.typed');
      foreach ($names as $name) {
        if (in_array($name$exclude, TRUE)) {
          // Skip checking schema if the config is listed in the           // $configSchemaCheckerExclusions property.           continue;
        }
        $config = $this->config($name);
        $this->assertConfigSchema($typed_config$name$config->get());
      }

      // Ensure that the update hooks updated all entity schema.       $needs_updates = \Drupal::entityDefinitionUpdateManager()->needsUpdates();
      if ($needs_updates) {
        foreach (\Drupal::entityDefinitionUpdateManager()->getChangeSummary() as $entity_type_id => $summary) {
          $entity_type_label = \Drupal::entityTypeManager()->getDefinition($entity_type_id)->getLabel();
          foreach ($summary as $message) {
            $this->fail("$entity_type_label: $message");
          }
        }
        
Home | Imprint | This part of the site doesn't use cookies.