1 field_ui.test public FieldUIViewModeFunctionalTest::testInfoHooks()

Test the new entity display mode hooks.

File

core/modules/field_ui/tests/field_ui.test, line 1026
Tests for field_ui.module.

Class

FieldUIViewModeFunctionalTest
Tests display mode functionality.

Code

public function testInfoHooks() {
  config_set('entity.view_modes', 'view_modes', array(
    'node' => array(
      'info_3' => array(
        'label' => t('Variable-altered display mode'),
        'custom settings' => TRUE,
      ),
    ),
    'taxonomy_term' => array(),
  ));
  $this->refreshVariables();

  $info = entity_get_info();

  // An invalid entity type in hook_entity_view_mode_info() does not pass
  // into the entity info array.
  $this->assertTrue(!isset($info['invalid-type']));

  // Test hook-provided display modes.
  $this->assertIdentical($info['node']['view modes']['info_1'], array(
    'label' => t('Hook-defined display mode #1'),
    'custom settings' => FALSE,
  ));
  $this->assertIdentical($info['node']['view modes']['info_2'], array(
    'label' => t('Hook-altered display mode'),
    'custom settings' => TRUE,
  ));
  $this->assertIdentical($info['node']['view modes']['info_3'], array(
    'label' => t('Variable-altered display mode'),
    'custom settings' => TRUE,
  ));
  $this->assertIdentical($info['taxonomy_term']['view modes']['info_1'], array(
    'label' => t('Hook-defined display mode #1'),
    'custom settings' => TRUE,
  ));

  // Test that entity display modes defined in hook_entity_info() are never
  // overridden by custom display modes.
  $this->assertIdentical($info['node']['view modes']['full'], array(
    'label' => 'Full content',
    'custom settings' => FALSE,
  ));
}