function ManageDisplayTest::testNonInitializedFields

Tests that field instances with no explicit display settings do not break.

File

drupal/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageDisplayTest.php, line 173
Definition of Drupal\field_ui\Tests\ManageDisplayTest.

Class

ManageDisplayTest
Tests the functionality of the 'Manage display' screens.

Namespace

Drupal\field_ui\Tests

Code

function testNonInitializedFields() {

  // Create a test field.
  $edit = array(
    'fields[_add_new_field][label]' => 'Test',
    'fields[_add_new_field][field_name]' => 'test',
  );
  $this
    ->fieldUIAddNewField('admin/structure/types/manage/' . $this->type, $edit);

  // Check that no settings have been set for the 'teaser' mode.
  $instance = field_info_instance('node', 'field_test', $this->type);
  $this
    ->assertFalse(isset($instance['display']['teaser']));

  // Check that the field appears as 'hidden' on the 'Manage display' page
  // for the 'teaser' mode.
  $this
    ->drupalGet('admin/structure/types/manage/' . $this->type . '/display/teaser');
  $this
    ->assertFieldByName('fields[field_test][type]', 'hidden', 'The field is displayed as \'hidden \'.');
}