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

Issue #3042538 by claudiu.cristea, Lendude: Convert ArgumentDefaultTest into a kernel test

parent de09969b
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\user\Traits\UserCreationTrait;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
/**
......@@ -9,7 +12,20 @@
*
* @group user
*/
class ArgumentDefaultTest extends UserTestBase {
class ArgumentDefaultTest extends KernelTestBase {
use UserCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'system',
'user',
'user_test_views',
'views',
];
/**
* Views used by this test.
......@@ -18,19 +34,24 @@ class ArgumentDefaultTest extends UserTestBase {
*/
public static $testViews = ['test_plugin_argument_default_current_user'];
public function test_plugin_argument_default_current_user() {
/**
* Tests the current user with argument default.
*/
public function testPluginArgumentDefaultCurrentUser() {
$this->installSchema('system', ['sequences']);
$this->installEntitySchema('user');
ViewTestData::createTestViews(get_class($this), ['user_test_views']);
// Create a user to test.
$account = $this->drupalCreateUser();
$account = $this->createUser();
// Switch the user.
\Drupal::service('account_switcher')->switchTo($account);
$this->container->get('account_switcher')->switchTo($account);
$view = Views::getView('test_plugin_argument_default_current_user');
$view->initHandlers();
$this->assertEqual($view->argument['null']->getDefaultArgument(), $account->id(), 'Uid of the current user is used.');
// Switch back.
\Drupal::service('account_switcher')->switchBack();
$this->assertEquals($account->id(), $view->argument['null']->getDefaultArgument(), 'Uid of the current user is used.');
}
}
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