You are here

protected function EntityFieldDefaultValueTest::assertDefaultValues in Zircon Profile 8

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

Executes a test set for a defined entity type.

Parameters

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

1 call to EntityFieldDefaultValueTest::assertDefaultValues()
EntityFieldDefaultValueTest::testDefaultValues in core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php
Tests default values on entities and fields.

File

core/modules/system/src/Tests/Entity/EntityFieldDefaultValueTest.php, line 49
Contains \Drupal\system\Tests\Entity\EntityFieldDefaultValueTest.

Class

EntityFieldDefaultValueTest
Tests default values for entity fields.

Namespace

Drupal\system\Tests\Entity

Code

protected function assertDefaultValues($entity_type_id) {
  $entity = entity_create($entity_type_id);
  $definition = $this->entityManager
    ->getDefinition($entity_type_id);
  $langcode_key = $definition
    ->getKey('langcode');
  $this
    ->assertEqual($entity->{$langcode_key}->value, 'en', SafeMarkup::format('%entity_type: Default language', array(
    '%entity_type' => $entity_type_id,
  )));
  $this
    ->assertTrue(Uuid::isValid($entity->uuid->value), SafeMarkup::format('%entity_type: Default UUID', array(
    '%entity_type' => $entity_type_id,
  )));
  $this
    ->assertEqual($entity->name
    ->getValue(), array(), 'Field has one empty value by default.');
}