diff --git a/core/modules/user/tests/src/Functional/Views/RelationshipRepresentativeNodeTest.php b/core/modules/user/tests/src/Functional/Views/RelationshipRepresentativeNodeTest.php deleted file mode 100644 index 6af661e665166d30ae06e88d481e562594e7e519..0000000000000000000000000000000000000000 --- a/core/modules/user/tests/src/Functional/Views/RelationshipRepresentativeNodeTest.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace Drupal\Tests\user\Functional\Views; - -use Drupal\views\Views; - -/** - * Tests the representative node relationship for users. - * - * @group user - */ -class RelationshipRepresentativeNodeTest extends UserTestBase { - - /** - * Views used by this test. - * - * @var array - */ - public static $testViews = ['test_groupwise_user']; - - /** - * Tests the relationship. - */ - public function testRelationship() { - $view = Views::getView('test_groupwise_user'); - $this->executeView($view); - $map = ['node_field_data_users_field_data_nid' => 'nid', 'uid' => 'uid']; - $expected_result = [ - [ - 'uid' => $this->users[1]->id(), - 'nid' => $this->nodes[1]->id(), - ], - [ - 'uid' => $this->users[0]->id(), - 'nid' => $this->nodes[0]->id(), - ], - ]; - $this->assertIdenticalResultset($view, $expected_result, $map); - } - -} diff --git a/core/modules/user/tests/src/Kernel/Views/RelationshipRepresentativeNodeTest.php b/core/modules/user/tests/src/Kernel/Views/RelationshipRepresentativeNodeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..6a067f259e7dd291798c9594caff5a6181370e18 --- /dev/null +++ b/core/modules/user/tests/src/Kernel/Views/RelationshipRepresentativeNodeTest.php @@ -0,0 +1,73 @@ +<?php + +namespace Drupal\Tests\user\Kernel\Views; + +use Drupal\KernelTests\KernelTestBase; +use Drupal\Tests\node\Traits\NodeCreationTrait; +use Drupal\Tests\user\Traits\UserCreationTrait; +use Drupal\views\Tests\ViewResultAssertionTrait; +use Drupal\views\Tests\ViewTestData; +use Drupal\views\Views; + +/** + * Tests the representative node relationship for users. + * + * @group user + */ +class RelationshipRepresentativeNodeTest extends KernelTestBase { + + use NodeCreationTrait; + use UserCreationTrait; + use ViewResultAssertionTrait; + + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'filter', + 'node', + 'system', + 'user', + 'user_test_views', + 'views', + ]; + + /** + * Views used by this test. + * + * @var array + */ + public static $testViews = ['test_groupwise_user']; + + /** + * Tests the relationship. + */ + public function testRelationship() { + $this->installSchema('system', ['sequences']); + $this->installEntitySchema('user'); + $this->installEntitySchema('node'); + $this->installConfig(['filter']); + ViewTestData::createTestViews(static::class, ['user_test_views']); + + $users[] = $this->createUser([], NULL, FALSE, ['uid' => 2]); + $users[] = $this->createUser([], NULL, FALSE, ['uid' => 1]); + $nodes[] = $this->createNode(['uid' => $users[0]->id()]); + $nodes[] = $this->createNode(['uid' => $users[1]->id()]); + + $view = Views::getView('test_groupwise_user'); + $view->preview(); + $map = ['node_field_data_users_field_data_nid' => 'nid', 'uid' => 'uid']; + $expected_result = [ + [ + 'uid' => $users[1]->id(), + 'nid' => $nodes[1]->id(), + ], + [ + 'uid' => $users[0]->id(), + 'nid' => $nodes[0]->id(), + ], + ]; + $this->assertIdenticalResultset($view, $expected_result, $map); + } + +}