public function FieldTemplateTest::testDsFieldTemplate in Display Suite 8.2
Tests on field templates.
File
- src/
Tests/ FieldTemplateTest.php, line 29
Class
- FieldTemplateTest
- Tests for display of nodes and fields.
Namespace
Drupal\ds\TestsCode
public function testDsFieldTemplate() {
// Get a node.
$node = $this
->entitiesTestSetup('hidden');
$body_field = $node->body->value;
// Default theming function.
$this
->drupalGet('node/' . $node
->id());
$xpath = $this
->xpath('//div[@class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"]');
$this
->assertTrimEqual($xpath[0]->p, $body_field);
$this
->entitiesSetLabelClass('above', 'body');
$this
->drupalGet('node/' . $node
->id());
$xpath = $this
->xpath('//div[@class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-above"]/div[@class="field__label"]');
$this
->assertTrimEqual($xpath[0], 'Body');
$xpath = $this
->xpath('//div[@class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-above"]/div[@class="field__item"]');
$this
->assertTrimEqual($xpath[0]->p, $body_field);
$this
->entitiesSetLabelClass('above', 'body', 'My body');
$this
->drupalGet('node/' . $node
->id());
$xpath = $this
->xpath('//div[@class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-above"]/div[@class="field__label"]');
$this
->assertTrimEqual($xpath[0], 'My body');
$xpath = $this
->xpath('//div[@class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-above"]/div[@class="field__item"]');
$this
->assertTrimEqual($xpath[0]->p, $body_field);
$this
->entitiesSetLabelClass('hidden', 'body', '', 'test_field_class');
$this
->drupalGet('node/' . $node
->id());
$xpath = $this
->xpath('//div[@class="test_field_class clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"]');
$this
->assertTrimEqual($xpath[0]->p, $body_field);
}