You are here

public function FieldFieldTest::testFieldAliasRender in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testFieldAliasRender()
  2. 10 core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testFieldAliasRender()

Tests the result of a view with complex field configuration.

A complex field configuration contains multiple times the same field, with different delta limit / offset.

File

core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php, line 330

Class

FieldFieldTest
Provides some integration tests for the Field handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testFieldAliasRender() {
  $executable = Views::getView('test_field_alias_test');
  $executable
    ->execute();
  for ($i = 0; $i < 5; $i++) {
    $this
      ->assertEquals((string) ($i + 1), $executable
      ->getStyle()
      ->getField($i, 'id'));
    $this
      ->assertEquals('test ' . $i, $executable
      ->getStyle()
      ->getField($i, 'name'));
    $entity = EntityTest::load($i + 1);
    $this
      ->assertEquals('<a href="' . $entity
      ->toUrl()
      ->toString() . '" hreflang="' . $entity
      ->language()
      ->getId() . '">test ' . $i . '</a>', (string) $executable
      ->getStyle()
      ->getField($i, 'name_alias'));
  }
}