You are here

public function FieldTemplateTest::testDsFieldTemplate4 in Display Suite 8.2

Tests on field templates.

File

src/Tests/FieldTemplateTest.php, line 180

Class

FieldTemplateTest
Tests for display of nodes and fields.

Namespace

Drupal\ds\Tests

Code

public function testDsFieldTemplate4() {

  // Get a node.
  $node = $this
    ->entitiesTestSetup('hidden');
  $body_field = $node->body->value;

  // With outer wrapper and field items wrapper.
  $edit = array(
    'fields[body][settings_edit_form][third_party_settings][ds][ft][id]' => 'expert',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'div',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'div',
  );
  $this
    ->dsEditFormatterSettings($edit);
  drupal_flush_all_caches();
  $this
    ->drupalGet('node/' . $node
    ->id());
  $xpath = $this
    ->xpath('//div[@class="group-right"]/div/div');
  $this
    ->assertTrimEqual($xpath[0]->p, $body_field);

  // With outer wrapper and field items div wrapper with class.
  $edit = array(
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'div',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'div',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class',
  );
  $this
    ->dsEditFormatterSettings($edit);
  $this
    ->drupalGet('node/' . $node
    ->id());
  $xpath = $this
    ->xpath('//div[@class="group-right"]/div/div[@class="fi-class"]');
  $this
    ->assertTrimEqual($xpath[0]->p, $body_field);

  // With outer wrapper and field items span wrapper and class.
  $edit = array(
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'div',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'span',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class',
  );
  $this
    ->dsEditFormatterSettings($edit);
  $this
    ->drupalGet('node/' . $node
    ->id());
  $xpath = $this
    ->xpath('//div[@class="group-right"]/div/span[@class="fi-class"]');
  $this
    ->assertTrimEqual($xpath[0]->p, $body_field);

  // With outer wrapper class and field items span wrapper and class.
  $edit = array(
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'div',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-cl]' => 'ow-class',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'span',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class',
  );
  $this
    ->dsEditFormatterSettings($edit);
  $this
    ->drupalGet('node/' . $node
    ->id());
  $xpath = $this
    ->xpath('//div[@class="group-right"]/div[@class="ow-class"]/span[@class="fi-class"]');
  $this
    ->assertTrimEqual($xpath[0]->p, $body_field);

  // With outer wrapper span class and field items span wrapper and class.
  $edit = array(
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-el]' => 'span',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][ow-cl]' => 'ow-class',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis]' => '1',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-el]' => 'span',
    'fields[body][settings_edit_form][third_party_settings][ds][ft][settings][fis-cl]' => 'fi-class-2',
  );
  $this
    ->dsEditFormatterSettings($edit);
  $this
    ->drupalGet('node/' . $node
    ->id());
  $xpath = $this
    ->xpath('//div[@class="group-right"]/span[@class="ow-class"]/span[@class="fi-class-2"]');
  $this
    ->assertTrimEqual($xpath[0]->p, $body_field);
}