diff --git a/core/modules/user/tests/src/Functional/Views/ArgumentDefaultTest.php b/core/modules/user/tests/src/Functional/Views/ArgumentDefaultTest.php deleted file mode 100644 index e14948ba2665f41f240e6951a4329e76c549e1f0..0000000000000000000000000000000000000000 --- a/core/modules/user/tests/src/Functional/Views/ArgumentDefaultTest.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Drupal\Tests\user\Functional\Views; - -use Drupal\views\Views; - -/** - * Tests views user argument default plugin. - * - * @group user - */ -class ArgumentDefaultTest extends UserTestBase { - - /** - * Views used by this test. - * - * @var array - */ - public static $testViews = ['test_plugin_argument_default_current_user']; - - public function test_plugin_argument_default_current_user() { - // Create a user to test. - $account = $this->drupalCreateUser(); - - // Switch the user. - \Drupal::service('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(); - } - -} diff --git a/core/modules/user/tests/src/Kernel/Views/ArgumentDefaultTest.php b/core/modules/user/tests/src/Kernel/Views/ArgumentDefaultTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c1e91b3b7123f953570ef781a438fd718f827af9 --- /dev/null +++ b/core/modules/user/tests/src/Kernel/Views/ArgumentDefaultTest.php @@ -0,0 +1,57 @@ +<?php + +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; + +/** + * Tests views user argument default plugin. + * + * @group user + */ +class ArgumentDefaultTest extends KernelTestBase { + + use UserCreationTrait; + + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'node', + 'system', + 'user', + 'user_test_views', + 'views', + ]; + + /** + * Views used by this test. + * + * @var array + */ + public static $testViews = ['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->createUser(); + + // Switch the user. + $this->container->get('account_switcher')->switchTo($account); + + $view = Views::getView('test_plugin_argument_default_current_user'); + $view->initHandlers(); + + $this->assertEquals($account->id(), $view->argument['null']->getDefaultArgument(), 'Uid of the current user is used.'); + } + +}