You are here

protected function DiscoveryTestBase::assertDefinitionIdentical in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php \Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase::assertDefinitionIdentical()

Asserts a definition against an expected definition.

Converts any instances of \Drupal\Core\Annotation\Translation to a string.

Parameters

array $definition: The definition to test.

array $expected_definition: The expected definition to test against.

1 call to DiscoveryTestBase::assertDefinitionIdentical()
DiscoveryTestBase::testDiscoveryInterface in core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php
Tests getDefinitions() and getDefinition().

File

core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php, line 70

Class

DiscoveryTestBase
Base class for plugin discovery tests.

Namespace

Drupal\KernelTests\Core\Plugin\Discovery

Code

protected function assertDefinitionIdentical(array $definition, array $expected_definition) {
  $func = function (&$item) {
    if ($item instanceof TranslatableMarkup) {
      $item = (string) $item;
    }
  };
  array_walk_recursive($definition, $func);
  array_walk_recursive($expected_definition, $func);
  $this
    ->assertSame($expected_definition, $definition);
}