EntityViewsWithMultivalueBasefieldTest.php in Drupal 9
File
core/modules/views/tests/src/Kernel/Entity/EntityViewsWithMultivalueBasefieldTest.php
View source
<?php
namespace Drupal\Tests\views\Kernel\Entity;
use Drupal\entity_test\Entity\EntityTestMultiValueBasefield;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
class EntityViewsWithMultivalueBasefieldTest extends ViewsKernelTestBase {
protected static $modules = [
'entity_test',
];
public static $testViews = [
'test_entity_multivalue_basefield',
];
protected function setUp($import_test_views = TRUE) : void {
parent::setUp($import_test_views);
$this
->installEntitySchema('entity_test_multivalue_basefield');
}
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',
]);
}
}