function FieldFieldTest::testComplexExecute

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testComplexExecute()
  2. 8.9.x core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testComplexExecute()
  3. 11.x core/modules/views/tests/src/Kernel/Handler/FieldFieldTest.php \Drupal\Tests\views\Kernel\Handler\FieldFieldTest::testComplexExecute()

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 374

Class

FieldFieldTest
Provides some integration tests for the Field handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testComplexExecute() : void {
    $executable = Views::getView('test_field_field_complex_test');
    $executable->execute();
    $timezones = [];
    foreach ($this->testUsers as $user) {
        $timezones[] = $user->getTimeZone();
    }
    $this->assertInstanceOf(EntityField::class, $executable->field['field_test_multiple']);
    $this->assertInstanceOf(EntityField::class, $executable->field['field_test_multiple_1']);
    $this->assertInstanceOf(EntityField::class, $executable->field['field_test_multiple_2']);
    $this->assertInstanceOf(EntityField::class, $executable->field['timezone']);
    $this->assertIdenticalResultset($executable, [
        [
            'timezone' => $timezones[0],
            'field_test_multiple' => [
                1,
                3,
            ],
            'field_test_multiple_1' => [
                1,
                3,
            ],
            'field_test_multiple_2' => [
                1,
                3,
            ],
        ],
        [
            'timezone' => $timezones[1],
            'field_test_multiple' => [
                7,
                0,
            ],
            'field_test_multiple_1' => [
                7,
                0,
            ],
            'field_test_multiple_2' => [
                7,
                0,
            ],
        ],
        [
            'timezone' => $timezones[2],
            'field_test_multiple' => [
                3,
                5,
            ],
            'field_test_multiple_1' => [
                3,
                5,
            ],
            'field_test_multiple_2' => [
                3,
                5,
            ],
        ],
        [
            'timezone' => $timezones[3],
            'field_test_multiple' => [
                9,
                9,
            ],
            'field_test_multiple_1' => [
                9,
                9,
            ],
            'field_test_multiple_2' => [
                9,
                9,
            ],
        ],
        [
            'timezone' => $timezones[4],
            'field_test_multiple' => [
                9,
                0,
            ],
            'field_test_multiple_1' => [
                9,
                0,
            ],
            'field_test_multiple_2' => [
                9,
                0,
            ],
        ],
    ], [
        'timezone' => 'timezone',
        'field_test_multiple' => 'field_test_multiple',
        'field_test_multiple_1' => 'field_test_multiple_1',
        'field_test_multiple_2' => 'field_test_multiple_2',
    ]);
}

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