EntityViewsWithMultivalueBaseFieldTest.php

Same filename and directory in other branches
  1. 9 core/modules/views/tests/src/Kernel/Entity/EntityViewsWithMultivalueBasefieldTest.php
  2. 8.9.x core/modules/views/tests/src/Kernel/Entity/EntityViewsWithMultivalueBasefieldTest.php
  3. 10 core/modules/views/tests/src/Kernel/Entity/EntityViewsWithMultivalueBasefieldTest.php

Namespace

Drupal\Tests\views\Kernel\Entity

File

core/modules/views/tests/src/Kernel/Entity/EntityViewsWithMultivalueBaseFieldTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\views\Kernel\Entity;

use Drupal\entity_test\Entity\EntityTestMultiValueBaseField;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
// cspell:ignore basefield

/**
 * Tests entity views with multivalue base fields.
 *
 * @group views
 */
class EntityViewsWithMultivalueBaseFieldTest extends ViewsKernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'entity_test',
  ];
  
  /**
   * {@inheritdoc}
   */
  public static $testViews = [
    'test_entity_multivalue_basefield',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected function setUp($import_test_views = TRUE) : void {
    parent::setUp($import_test_views);
    $this->installEntitySchema('entity_test_multivalue_basefield');
  }
  
  /**
   * Tests entity views with multivalue base fields.
   */
  public function testView() : void {
    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',
    ]);
  }

}

Classes

Title Deprecated Summary
EntityViewsWithMultivalueBaseFieldTest Tests entity views with multivalue base fields.

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