You are here

protected function EntityFieldTest::doTestDataStructureInterfaces in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/EntityFieldTest.php \Drupal\system\Tests\Entity\EntityFieldTest::doTestDataStructureInterfaces()

Executes the data structure interfaces tests for the given entity type.

Parameters

string $entity_type: The entity type to run the tests with.

1 call to EntityFieldTest::doTestDataStructureInterfaces()
EntityFieldTest::testDataStructureInterfaces in core/modules/system/src/Tests/Entity/EntityFieldTest.php
Tests working with the entity based upon the TypedData API.

File

core/modules/system/src/Tests/Entity/EntityFieldTest.php, line 540
Contains \Drupal\system\Tests\Entity\EntityFieldTest.

Class

EntityFieldTest
Tests the Entity Field API.

Namespace

Drupal\system\Tests\Entity

Code

protected function doTestDataStructureInterfaces($entity_type) {
  $entity = $this
    ->createTestEntity($entity_type);

  // Test using the whole tree of typed data by navigating through the tree of
  // contained properties and getting all contained strings, limited by a
  // certain depth.
  $strings = array();
  $this
    ->getContainedStrings($entity
    ->getTypedData(), 0, $strings);

  // @todo: Once the user entity has defined properties this should contain
  // the user name and other user entity strings as well.
  $target_strings = array(
    $entity->uuid->value,
    'en',
    $this->entityName,
    // Bundle name.
    $entity
      ->bundle(),
    $this->entityFieldText,
    // Field format.
    NULL,
  );
  asort($strings);
  asort($target_strings);
  $this
    ->assertEqual(array_values($strings), array_values($target_strings), format_string('%entity_type: All contained strings found.', array(
    '%entity_type' => $entity_type,
  )));
}