public function EntityFieldTest::testDataStructureInterfaces

Tests working with entity properties based upon data structure and data list interfaces.

File

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

Class

EntityFieldTest
Tests Entity API base functionality.

Namespace

Drupal\system\Tests\Entity

Code

public function testDataStructureInterfaces() {
  $entity = $this
    ->createTestEntity();
  $entity
    ->save();
  $entity_definition = array(
    'type' => 'entity',
    'constraints' => array(
      'entity type' => 'entity_test',
    ),
    'label' => t('Test entity'),
  );
  $wrapped_entity = typed_data()
    ->create($entity_definition, $entity);

  // For the test we navigate through the tree of contained properties and get
  // 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_NOT_SPECIFIED,
    $this->entity_name,
    $this->entity_field_text,
    // Field format.
    NULL,
  );
  $this
    ->assertEqual($strings, $target_strings, 'All contained strings found.');
}