Skip to content
Snippets Groups Projects
Unverified Commit 5aa09075 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3042540 by claudiu.cristea, Lendude: Convert user...

Issue #3042540 by claudiu.cristea, Lendude: Convert user RelationshipRepresentativeNodeTest into a kernel test
parent 674251e8
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
<?php
namespace Drupal\Tests\user\Functional\Views;
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;
/**
......@@ -9,7 +14,23 @@
*
* @group user
*/
class RelationshipRepresentativeNodeTest extends UserTestBase {
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.
......@@ -22,17 +43,28 @@ class RelationshipRepresentativeNodeTest extends UserTestBase {
* 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');
$this->executeView($view);
$view->preview();
$map = ['node_field_data_users_field_data_nid' => 'nid', 'uid' => 'uid'];
$expected_result = [
[
'uid' => $this->users[1]->id(),
'nid' => $this->nodes[1]->id(),
'uid' => $users[1]->id(),
'nid' => $nodes[1]->id(),
],
[
'uid' => $this->users[0]->id(),
'nid' => $this->nodes[0]->id(),
'uid' => $users[0]->id(),
'nid' => $nodes[0]->id(),
],
];
$this->assertIdenticalResultset($view, $expected_result, $map);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment