You are here

protected function DiscoveryTestBase::assertDefinitionIdentical in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php \Drupal\system\Tests\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/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php
Tests getDefinitions() and getDefinition().

File

core/modules/system/src/Tests/Plugin/Discovery/DiscoveryTestBase.php, line 78
Contains \Drupal\system\Tests\Plugin\Discovery\DiscoveryTestBase.

Class

DiscoveryTestBase
Base class for plugin discovery tests.

Namespace

Drupal\system\Tests\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);
}