function ArgumentDefaultTest::testPluginArgumentDefaultCurrentUser

Same name in other branches
  1. 9 core/modules/user/tests/src/Kernel/Views/ArgumentDefaultTest.php \Drupal\Tests\user\Kernel\Views\ArgumentDefaultTest::testPluginArgumentDefaultCurrentUser()
  2. 8.9.x core/modules/user/tests/src/Kernel/Views/ArgumentDefaultTest.php \Drupal\Tests\user\Kernel\Views\ArgumentDefaultTest::testPluginArgumentDefaultCurrentUser()
  3. 10 core/modules/user/tests/src/Kernel/Views/ArgumentDefaultTest.php \Drupal\Tests\user\Kernel\Views\ArgumentDefaultTest::testPluginArgumentDefaultCurrentUser()

Tests the current user with argument default.

File

core/modules/user/tests/src/Kernel/Views/ArgumentDefaultTest.php, line 42

Class

ArgumentDefaultTest
Tests views user argument default plugin.

Namespace

Drupal\Tests\user\Kernel\Views

Code

public function testPluginArgumentDefaultCurrentUser() : void {
    $this->installEntitySchema('user');
    ViewTestData::createTestViews(static::class, [
        '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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.