You are here

ExtraFieldDisplayFieldTest.php in Extra Field 8.2

Same filename and directory in other branches
  1. 8 tests/src/Functional/ExtraFieldDisplayFieldTest.php

File

tests/src/Functional/ExtraFieldDisplayFieldTest.php
View source
<?php

namespace Drupal\Tests\extra_field\Functional;


/**
 * Tests the extra_field Display with field wrapper.
 *
 * @group extra_field
 */
class ExtraFieldDisplayFieldTest extends ExtraFieldBrowserTestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = [
    'extra_field',
    'extra_field_test',
    'node',
  ];

  /**
   * A node that contains the extra fields.
   *
   * @var \Drupal\node\Entity\Node
   */
  protected $firstNode;

  /**
   * A second node.
   *
   * @var \Drupal\node\Entity\Node
   */
  protected $secondNode;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->firstNode = $this
      ->createContent('first_node_type');
    $this->secondNode = $this
      ->createContent('another_node_type');
  }

  /**
   * Test the output of field with single value item.
   */
  public function testFirstNodeTypeFields() {
    $url = $this->firstNode
      ->toUrl();
    $this
      ->drupalGet($url);

    // Test the output of field with single value item.
    $this
      ->assertSession()
      ->pageTextContains('Output from SingleTextFieldTest');
    $this
      ->assertSession()
      ->pageTextContains('Single text');

    // Test the output of field with multiple value items.
    $this
      ->assertSession()
      ->pageTextContains('Aap');
    $this
      ->assertSession()
      ->pageTextContains('Noot');
    $this
      ->assertSession()
      ->pageTextContains('Zus');

    // Test the output of field with cacheable dependency.
    $this
      ->assertSession()
      ->pageTextContains('Related pages');
    $this
      ->assertSession()
      ->pageTextContains($this->secondNode
      ->label());
    $this
      ->assertCacheTag('node:' . $this->secondNode
      ->id());

    // Test the output of the empty field.
    $this
      ->assertSession()
      ->pageTextNotContains('Empty field');
  }

}

Classes

Namesort descending Description
ExtraFieldDisplayFieldTest Tests the extra_field Display with field wrapper.