function FieldStorageIndexesValidationTest::testValidIndexes
Same name and namespace in other branches
- 11.x core/modules/field/tests/src/Kernel/Config/FieldStorageIndexesValidationTest.php \Drupal\Tests\field\Kernel\Config\FieldStorageIndexesValidationTest::testValidIndexes()
Test valid indexes.
Attributes
#[Test]
File
-
core/
modules/ field/ tests/ src/ Kernel/ Config/ FieldStorageIndexesValidationTest.php, line 50
Class
- FieldStorageIndexesValidationTest
- Tests validation for field storage indexes config.
Namespace
Drupal\Tests\field\Kernel\ConfigCode
public function testValidIndexes() : void {
$config = \Drupal::configFactory()->getEditable('field.storage.entity_test.field_test_import');
$typed_config_manager = \Drupal::service('config.typed');
$valid_indexes = [
[
'value_format' => [
[
'value',
127,
],
[
'format',
127,
],
],
],
[
'format' => [
'value',
],
],
[
'foo1' => [
'value',
'format',
],
],
[
'foo2' => [
'value',
'format',
],
'bar2' => [
'value',
],
],
[
'foo4' => [
'value',
'format',
],
'bar4' => [
'value',
[
'format',
127,
],
],
],
[
'foo5' => [],
],
];
foreach ($valid_indexes as $indexes) {
$config->set('indexes', $indexes);
$typed_config = $typed_config_manager->createFromNameAndData($config->getName(), $config->get());
/** @var \Symfony\Component\Validator\ConstraintViolationListInterface $errors */
$errors = $typed_config->validate();
$this->assertCount(0, $errors, 'Expected no validation violations: ' . $errors . '. Indexes: ' . print_r($indexes, TRUE));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.