public function ArgumentDefaultTest::testPluginArgumentDefaultCurrentUser in Drupal 8
Same name and namespace in other branches
- 9 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 40
Class
- ArgumentDefaultTest
- Tests views user argument default plugin.
Namespace
Drupal\Tests\user\Kernel\ViewsCode
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.');
}