Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / user / tests / src / Functional / Views / ArgumentDefaultTest.php
diff --git a/web/core/modules/user/tests/src/Functional/Views/ArgumentDefaultTest.php b/web/core/modules/user/tests/src/Functional/Views/ArgumentDefaultTest.php
new file mode 100644 (file)
index 0000000..e14948b
--- /dev/null
@@ -0,0 +1,36 @@
+<?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();
+  }
+
+}