You are here

protected function DiscoveryTestBase::assertDefinitionIdentical in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Plugin/Discovery/DiscoveryTestBase.php \Drupal\KernelTests\Core\Plugin\Discovery\DiscoveryTestBase::assertDefinitionIdentical()
  2. 10 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.

Return value

bool TRUE if the assertion succeeded, FALSE otherwise.

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 73

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);
  return $this
    ->assertIdentical($definition, $expected_definition);
}