You are here

public function ArgumentDefaultTest::test_plugin_argument_default_current_user in Views (for Drupal 7) 8.3

File

lib/Drupal/views/Tests/User/ArgumentDefaultTest.php, line 23
Definition of Drupal\views\Tests\User\ArgumentDefaultTest.

Class

ArgumentDefaultTest
Tests views user argument default plugin.

Namespace

Drupal\views\Tests\User

Code

public function test_plugin_argument_default_current_user() {

  // Create a user to test.
  $account = $this
    ->drupalCreateUser();

  // Switch the user, we have to check the global user too, because drupalLogin is only for the simpletest browser.
  $this
    ->drupalLogin($account);
  global $user;
  $admin = $user;
  drupal_save_session(FALSE);
  $user = $account;
  $this->view
    ->preExecute();
  $this->view
    ->initHandlers();
  $this
    ->assertEqual($this->view->argument['null']
    ->get_default_argument(), $account->uid, 'Uid of the current user is used.');

  // Switch back.
  $user = $admin;
  drupal_save_session(TRUE);
}