You are here

public function EntityReferenceFieldFormatterTest::testImageFieldFormatter in Entity Embed 7.3

Tests image field formatter Entity Embed Display plugin.

File

./entity_embed.test, line 523
Test integration for the entity_embed module.

Class

EntityReferenceFieldFormatterTest
Tests the entity reference field formatter provided by entity_embed.

Code

public function testImageFieldFormatter() {

  // Ensure that entity reference field formatters are available as plugins.
  $this
    ->assertAvailableDisplayPlugins('file', array(
    'entityreference_label',
    'entityreference_entity_id',
    'entityreference_entity_view',
  ));

  // Ensure that correct form attributes are returned for
  // 'entityreference:entityreference_entity_id' plugin.
  $form = array();
  $form_state = form_state_defaults();
  $conf_form = entity_embed_field_info_formatter_settings('node', $this->node, 'entityreference_entity_id', array(), $form, $form_state);
  $this
    ->assertIdentical(array_keys($conf_form), array());

  // Ensure that correct form attributes are returned for
  // 'entityreference:entity_reference:entityreference_entity_view' plugin.
  $form = array();
  $form_state = form_state_defaults();
  $conf_form = entity_embed_field_info_formatter_settings('node', $this->node, 'entityreference_entity_view', array(), $form, $form_state);
  $this
    ->assertIdentical(array_keys($conf_form), array(
    'view_mode',
    'links',
  ));
  $this
    ->assertIdentical($conf_form['view_mode']['#type'], 'select');
  $this
    ->assertIdentical((string) $conf_form['view_mode']['#title'], 'View mode');
  $this
    ->assertIdentical($conf_form['links']['#type'], 'checkbox');
  $this
    ->assertIdentical((string) $conf_form['links']['#title'], 'Show links');

  // Ensure that correct form attributes are returned for
  // 'entityreference:entity_reference:entityreference_label' plugin.
  $form = array();
  $form_state = form_state_defaults();
  $conf_form = entity_embed_field_info_formatter_settings('node', $this->node, 'entityreference_label', array(), $form, $form_state);
  $this
    ->assertIdentical(array_keys($conf_form), array(
    'link',
  ));
  $this
    ->assertIdentical($conf_form['link']['#type'], 'checkbox');
  $this
    ->assertIdentical((string) $conf_form['link']['#title'], 'Link label to the referenced entity');
}