You are here

public function FieldGroupLinkDisplayTest::testEntityReference in Field Group Link 8.3

Test the entity reference link type.

File

tests/src/Functional/FieldGroupLinkDisplayTest.php, line 193

Class

FieldGroupLinkDisplayTest
Tests for displaying entities.

Namespace

Drupal\Tests\field_group_link\Functional

Code

public function testEntityReference() {
  $data = array(
    'weight' => '1',
    'children' => array(
      0 => 'field_test',
      1 => 'body',
    ),
    'label' => 'Test Link',
    'format_type' => 'link',
    'format_settings' => array(
      'target' => 'field_test_entity_reference',
      'classes' => 'test-link-class',
    ),
  );
  $this
    ->createGroup('node', $this->type, 'view', 'default', $data);
  $this
    ->drupalGet('node/' . $this->node
    ->id());
  $this
    ->assertSession()
    ->elementContains('css', '.test-link-class', $this->testFieldValue);

  // Test group ids and classes.
  $this
    ->click('.test-link-class');
  $this
    ->assertSession()
    ->addressEquals($this->referencedNode
    ->toUrl('canonical', [
    'absolute' => TRUE,
  ]));
}