function FieldFieldTest::testRevisionComplexExecute

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

Tests the result set of a complex revision view.

File

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

Class

FieldFieldTest
Provides some integration tests for the Field handler.

Namespace

Drupal\Tests\views\Kernel\Handler

Code

public function testRevisionComplexExecute() : void {
    $executable = Views::getView('test_field_field_revision_complex_test');
    $executable->execute();
    $timezones = [];
    foreach ($this->testUsers as $user) {
        $timezones[] = $user->getTimeZone();
    }
    $this->assertInstanceOf(EntityField::class, $executable->field['id']);
    $this->assertInstanceOf(EntityField::class, $executable->field['revision_id']);
    $this->assertInstanceOf(EntityField::class, $executable->field['timezone']);
    $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->assertIdenticalResultset($executable, [
        [
            'id' => 1,
            'field_test' => 1,
            'revision_id' => 1,
            'uid' => $this->testUsers[0]
                ->id(),
            'timezone' => $timezones[0],
            'field_test_multiple' => [
                1,
                3,
                7,
            ],
            'field_test_multiple_1' => [
                1,
                3,
                7,
            ],
            'field_test_multiple_2' => [
                1,
                3,
                7,
            ],
        ],
        [
            'id' => 1,
            'field_test' => 2,
            'revision_id' => 2,
            'uid' => $this->testUsers[1]
                ->id(),
            'timezone' => $timezones[1],
            'field_test_multiple' => [
                0,
                3,
                5,
            ],
            'field_test_multiple_1' => [
                0,
                3,
                5,
            ],
            'field_test_multiple_2' => [
                0,
                3,
                5,
            ],
        ],
        [
            'id' => 1,
            'field_test' => 3,
            'revision_id' => 3,
            'uid' => $this->testUsers[2]
                ->id(),
            'timezone' => $timezones[2],
            'field_test_multiple' => [
                9,
                9,
                9,
            ],
            'field_test_multiple_1' => [
                9,
                9,
                9,
            ],
            'field_test_multiple_2' => [
                9,
                9,
                9,
            ],
        ],
        [
            'id' => 2,
            'field_test' => 4,
            'revision_id' => 4,
            'uid' => $this->testUsers[3]
                ->id(),
            'timezone' => $timezones[3],
            'field_test_multiple' => [
                2,
                9,
                9,
            ],
            'field_test_multiple_1' => [
                2,
                9,
                9,
            ],
            'field_test_multiple_2' => [
                2,
                9,
                9,
            ],
        ],
    ], [
        'entity_test_rev_revision_id' => 'id',
        'revision_id' => 'revision_id',
        'users_field_data_entity_test_rev_revision_uid' => 'uid',
        '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.