function FieldFieldTest::testFieldAliasRender

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testFieldAliasRender()
  2. 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testFieldAliasRender()
  3. 11.x 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 335

Class

FieldFieldTest
Provides some integration tests for the Field handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testFieldAliasRender() : void {
    $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'));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.