You are here

public function ViewsUserArgumentDefault::test_plugin_argument_default_current_user in Views (for Drupal 7) 7.3

File

tests/user/views_user_argument_default.test, line 27
Definition of ViewsUserArgumentDefault.

Class

ViewsUserArgumentDefault
Tests views user argument default plugin.

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;
  $view = $this
    ->view_plugin_argument_default_current_user();
  $view
    ->set_display('default');
  $view
    ->pre_execute();
  $view
    ->init_handlers();
  $this
    ->assertEqual($view->argument['null']
    ->get_default_argument(), $account->uid, 'Uid of the current user is used.');

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