Verified Commit 56aeb822 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3398974 follow-up by Wim Leers: Follow-up for #3382510:...

Issue #3398974 follow-up by Wim Leers: Follow-up for #3382510: FormStateInterface::setErrorByName() needs not #name but a variation

(cherry picked from commit f9109dc8)
parent 60367575
Loading
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -192,11 +192,6 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
          $property_path = rtrim($property_path, '0123456789.');
        }

        if ($property_path === '') {
          // There is a map to a non-existing config key. Try to work backwards.
          $property_path = $violation->getParameters()['@key'] ?? '';
        }

        if (isset($map["$config_name:$property_path"])) {
          $form_element_name = implode('][', $map["$config_name:$property_path"]->elementParents);
        }
+5 −1
Original line number Diff line number Diff line
@@ -35,7 +35,11 @@ public function validate(mixed $value, Constraint $constraint) {
      $constraint->getAllowedKeys($this->context)
    );
    foreach ($invalid_keys as $key) {
      $this->context->addViolation($constraint->invalidKeyMessage, ['@key' => $key]);
      $this->context->buildViolation($constraint->invalidKeyMessage)
        ->setParameter('@key', $key)
        ->atPath($key)
        ->setInvalidValue($key)
        ->addViolation();
    }
  }

+2 −2
Original line number Diff line number Diff line
@@ -310,8 +310,8 @@ public function testBlockMigration() {
    $this->assertCount(4, $messages);
    $this->assertSame($messages[0]->message, 'Schema errors for block.block.block_1 with the following errors: 0 [dependencies.theme.0] Theme 'bluemarine' is not installed.');
    $this->assertSame($messages[1]->message, "d6_block:visibility: The block with bid '13' from module 'block' will have no PHP or request_path visibility configuration.");
    $this->assertSame($messages[2]->message, 'Schema errors for block.block.aggregator with the following errors: block.block.aggregator:settings.block_count missing schema, block.block.aggregator:settings.feed missing schema, 0 [settings] 'block_count' is not a supported key., 1 [settings] 'feed' is not a supported key.');
    $this->assertSame($messages[3]->message, 'Schema errors for block.block.book with the following errors: block.block.book:settings.block_mode missing schema, 0 [settings] 'block_mode' is not a supported key.');
    $this->assertSame($messages[2]->message, 'Schema errors for block.block.aggregator with the following errors: block.block.aggregator:settings.block_count missing schema, block.block.aggregator:settings.feed missing schema, 0 [settings.block_count] 'block_count' is not a supported key., 1 [settings.feed] 'feed' is not a supported key.');
    $this->assertSame($messages[3]->message, 'Schema errors for block.block.book with the following errors: block.block.book:settings.block_mode missing schema, 0 [settings.block_mode] 'block_mode' is not a supported key.');
  }

}
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ public function testConfigSchemaChecker() {
      $this->fail('Expected SchemaIncompleteException thrown');
    }
    catch (SchemaIncompleteException $e) {
      $this->assertEquals("Schema errors for config_test.types with the following errors: config_test.types:array variable type is integer but applied schema class is Drupal\Core\Config\Schema\Sequence, config_test.types:foo missing schema, 0 [] 'foo' is not a supported key.", $e->getMessage());
      $this->assertEquals("Schema errors for config_test.types with the following errors: config_test.types:array variable type is integer but applied schema class is Drupal\Core\Config\Schema\Sequence, config_test.types:foo missing schema, 0 [foo] 'foo' is not a supported key.", $e->getMessage());
    }

    // Test that the config event listener is working in the child site.
+2 −2
Original line number Diff line number Diff line
@@ -185,9 +185,9 @@ public function testSimpleConfigValidation() {
    // 2 constraint violations triggered by the default validation constraint
    // for `type: mapping`
    // @see \Drupal\Core\Validation\Plugin\Validation\Constraint\ValidKeysConstraint
    $this->assertSame('', $result->get(0)->getPropertyPath());
    $this->assertSame('elephant', $result->get(0)->getPropertyPath());
    $this->assertEquals("'elephant' is not a supported key.", $result->get(0)->getMessage());
    $this->assertSame('', $result->get(1)->getPropertyPath());
    $this->assertSame('zebra', $result->get(1)->getPropertyPath());
    $this->assertEquals("'zebra' is not a supported key.", $result->get(1)->getMessage());
    // 1 additional constraint violation triggered by the custom
    // constraint for the `config_test.validation` type, which indirectly
Loading