class EntityViewsWithMultivalueBasefieldTest

Same name and namespace in other branches
  1. 11.x core/modules/views/tests/src/Kernel/Entity/EntityViewsWithMultivalueBaseFieldTest.php \Drupal\Tests\views\Kernel\Entity\EntityViewsWithMultivalueBaseFieldTest

Tests entity views with multivalue base fields.

@group views

Hierarchy

Expanded class hierarchy of EntityViewsWithMultivalueBasefieldTest

File

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

Namespace

Drupal\Tests\views\Kernel\Entity
View source
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() {
    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',
    ]);
  }

}

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