You are here

public function EntityDisplayTest::testExtraFieldComponent in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field_ui/src/Tests/EntityDisplayTest.php \Drupal\field_ui\Tests\EntityDisplayTest::testExtraFieldComponent()

Tests the behavior of a field component within an entity display object.

File

core/modules/field_ui/src/Tests/EntityDisplayTest.php, line 162
Contains \Drupal\field_ui\Tests\EntityDisplayTest.

Class

EntityDisplayTest
Tests the entity display configuration entities.

Namespace

Drupal\field_ui\Tests

Code

public function testExtraFieldComponent() {
  entity_test_create_bundle('bundle_with_extra_fields');
  $display = EntityViewDisplay::create(array(
    'targetEntityType' => 'entity_test',
    'bundle' => 'bundle_with_extra_fields',
    'mode' => 'default',
  ));

  // Check that the default visibility taken into account for extra fields
  // unknown in the display.
  $this
    ->assertEqual($display
    ->getComponent('display_extra_field'), array(
    'weight' => 5,
  ));
  $this
    ->assertNull($display
    ->getComponent('display_extra_field_hidden'));

  // Check that setting explicit options overrides the defaults.
  $display
    ->removeComponent('display_extra_field');
  $display
    ->setComponent('display_extra_field_hidden', array(
    'weight' => 10,
  ));
  $this
    ->assertNull($display
    ->getComponent('display_extra_field'));
  $this
    ->assertEqual($display
    ->getComponent('display_extra_field_hidden'), array(
    'weight' => 10,
    'settings' => array(),
    'third_party_settings' => array(),
  ));
}