You are here

public function EntityViewsWithMultivalueBasefieldTest::testView in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Kernel/Entity/EntityViewsWithMultivalueBasefieldTest.php \Drupal\Tests\views\Kernel\Entity\EntityViewsWithMultivalueBasefieldTest::testView()

Tests entity views with multivalue base fields.

File

core/modules/views/tests/src/Kernel/Entity/EntityViewsWithMultivalueBasefieldTest.php, line 38

Class

EntityViewsWithMultivalueBasefieldTest
Tests entity views with multivalue base fields.

Namespace

Drupal\Tests\views\Kernel\Entity

Code

public function testView() {
  EntityTestMultiValueBasefield::create([
    'name' => 'test',
  ])
    ->save();
  EntityTestMultiValueBasefield::create([
    'name' => [
      'test2',
      'test3',
    ],
  ])
    ->save();
  $view = Views::getView('test_entity_multivalue_basefield');
  $view
    ->execute();
  $this
    ->assertIdenticalResultset($view, [
    [
      'name' => [
        'test',
      ],
    ],
    [
      'name' => [
        'test2',
        'test3',
      ],
    ],
  ], [
    'name' => 'name',
  ]);
}