protected function EntityFieldTest::assertDataStructureInterfaces

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::assertDataStructureInterfaces()
EntityFieldTest::testDataStructureInterfaces in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Tests working with the entity based upon the TypedData API.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php, line 471
Definition of Drupal\system\Tests\Entity\EntityFieldTest.

Class

EntityFieldTest
Tests Entity API base functionality.

Namespace

Drupal\system\Tests\Entity

Code

protected function assertDataStructureInterfaces($entity_type) {
  $entity = $this
    ->createTestEntity($entity_type);
  $entity
    ->save();
  $entity_definition = array(
    'type' => 'entity',
    'constraints' => array(
      'EntityType' => $entity_type,
    ),
    'label' => 'Test entity',
  );
  $wrapped_entity = $this->container
    ->get('typed_data')
    ->create($entity_definition, $entity);

  // 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($wrapped_entity, 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,
    Language::LANGCODE_NOT_SPECIFIED,
    $this->entity_name,
    // Bundle name.
    $entity
      ->bundle(),
    $this->entity_field_text,
    // Field format.
    NULL,
  );
  $this
    ->assertEqual($strings, $target_strings, format_string('%entity_type: All contained strings found.', array(
    '%entity_type' => $entity_type,
  )));
}