public function EntityDisplayTest::testExtraFieldComponent

Tests the behavior of a field component within an EntityDisplay object.

File

drupal/core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php, line 111
Contains \Drupal\entity\Tests\EntityDisplayTest.

Class

EntityDisplayTest
Tests the EntityDisplay configuration entities.

Namespace

Drupal\entity\Tests

Code

public function testExtraFieldComponent() {
  $display = entity_create('entity_display', array(
    'targetEntityType' => 'entity_test',
    'bundle' => 'entity_test',
    '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,
  ));
}