You are here

public function DsTestTrait::entitiesTestSetup in Display Suite 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/DsTestTrait.php \Drupal\Tests\ds\Functional\DsTestTrait::entitiesTestSetup()

Utility function to setup for all kinds of tests.

Parameters

string $label: How the body label must be set.

12 calls to DsTestTrait::entitiesTestSetup()
DynamicFieldPluginTest::testDsFields in tests/src/Functional/DynamicFieldPluginTest.php
Test Display fields.
EntitiesTest::testDsNodeEntity in tests/src/Functional/EntitiesTest.php
Test basic node display fields.
FieldTemplateTest::testDsFieldTemplate in tests/src/Functional/FieldTemplateTest.php
Tests on field templates.
FieldTemplateTest::_testDsFieldTemplate2 in tests/src/Functional/FieldTemplateTest.php
Tests on field templates.
FieldTemplateTest::_testDsFieldTemplate3 in tests/src/Functional/FieldTemplateTest.php
Tests on field templates.

... See full list

File

tests/src/Functional/DsTestTrait.php, line 151

Class

DsTestTrait
Provides common functionality for the Display Suite test classes.

Namespace

Drupal\Tests\ds\Functional

Code

public function entitiesTestSetup($label = 'above') {

  // Create a node.
  $settings = [
    'type' => 'article',
    'promote' => 1,
  ];
  $node = $this
    ->drupalCreateNode($settings);

  // Create field CSS classes.
  $edit = [
    'fields' => "test_field_class\ntest_field_class_2|Field class 2\n[node:nid]",
  ];
  $this
    ->drupalPostForm('admin/structure/ds/classes', $edit, 'Save configuration');

  // Create a token field.
  $token_field = [
    'name' => 'Token field',
    'id' => 'token_field',
    'entities[node]' => '1',
    'content[value]' => '[node:title]',
  ];
  $this
    ->dsCreateTokenField($token_field);

  // Select layout.
  $this
    ->dsSelectLayout();

  // Configure fields.
  $fields = [
    'fields[dynamic_token_field:node-token_field][region]' => 'header',
    'fields[body][region]' => 'right',
    'fields[node_link][region]' => 'footer',
    'fields[body][label]' => $label,
    'fields[node_submitted_by][region]' => 'header',
  ];
  $this
    ->dsConfigureUi($fields);
  return $node;
}