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

Issue #3046937 by claudiu.cristea, naveenvalecha: Convert TrackerUserUidTest...

Issue #3046937 by claudiu.cristea, naveenvalecha: Convert TrackerUserUidTest into a Kernel test. Deprecate TrackerTestBase
parent 3a1d2047
Branches
Tags
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
......@@ -2,6 +2,8 @@
namespace Drupal\Tests\tracker\Functional\Views;
@trigger_error('The ' . __NAMESPACE__ . '\TrackerTestBase is deprecated in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead, use Kernel tests to test tracker module views plugins integration. https://www.drupal.org/node/3046938', E_USER_DEPRECATED);
use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Tests\views\Functional\ViewTestBase;
......@@ -10,6 +12,11 @@
/**
* Base class for all tracker tests.
*
* @deprecated in Drupal 8.8.0 and will be removed before Drupal 9.0.0. Instead,
* use Kernel tests to test tracker module views plugins integration.
*
* @see https://www.drupal.org/node/3046938
*/
abstract class TrackerTestBase extends ViewTestBase {
......
<?php
namespace Drupal\Tests\tracker\Functional\Views;
namespace Drupal\Tests\tracker\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,24 @@
*
* @group tracker
*/
class TrackerUserUidTest extends TrackerTestBase {
class TrackerUserUidTest extends KernelTestBase {
use NodeCreationTrait;
use UserCreationTrait;
use ViewResultAssertionTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'filter',
'node',
'system',
'tracker',
'tracker_test_views',
'user',
'views',
];
/**
* Views used by this test.
......@@ -22,6 +44,15 @@ class TrackerUserUidTest extends TrackerTestBase {
* Tests the user uid filter and argument.
*/
public function testUserUid() {
$this->installSchema('system', ['sequences']);
$this->installConfig(['filter']);
$this->installEntitySchema('user');
$this->installEntitySchema('node');
$this->installSchema('tracker', ['tracker_node', 'tracker_user']);
ViewTestData::createTestViews(static::class, ['tracker_test_views']);
$node = $this->createNode();
$map = [
'nid' => 'nid',
'title' => 'title',
......@@ -29,13 +60,13 @@ public function testUserUid() {
$expected = [
[
'nid' => $this->node->id(),
'title' => $this->node->label(),
'nid' => $node->id(),
'title' => $node->label(),
],
];
$view = Views::getView('test_tracker_user_uid');
$this->executeView($view);
$view->preview();
// We should have no results as the filter is set for uid 0.
$this->assertIdenticalResultSet($view, [], $map);
......@@ -43,8 +74,8 @@ public function testUserUid() {
// Change the filter value to our user.
$view->initHandlers();
$view->filter['uid_touch_tracker']->value = $this->node->getOwnerId();
$this->executeView($view);
$view->filter['uid_touch_tracker']->value = $node->getOwnerId();
$view->preview();
// We should have one result as the filter is set for the created user.
$this->assertIdenticalResultSet($view, $expected, $map);
......@@ -55,13 +86,13 @@ public function testUserUid() {
// Test the incorrect argument UID.
$view->initHandlers();
$this->executeView($view, [rand()]);
$view->preview(NULL, [rand()]);
$this->assertIdenticalResultSet($view, [], $map);
$view->destroy();
// Test the correct argument UID.
$view->initHandlers();
$this->executeView($view, [$this->node->getOwnerId()]);
$view->preview(NULL, [$node->getOwnerId()]);
$this->assertIdenticalResultSet($view, $expected, $map);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment