3 namespace Drupal\user\Tests\Views;
5 use Drupal\views\Views;
8 * Tests the handler of the user: uid Argument.
12 class HandlerArgumentUserUidTest extends UserTestBase {
15 * Views used by this test.
19 public static $testViews = ['test_user_uid_argument'];
22 * Tests the generated title of an user: uid argument.
24 public function testArgumentTitle() {
25 $view = Views::getView('test_user_uid_argument');
27 // Tests an invalid user uid.
28 $this->executeView($view, [rand(1000, 10000)]);
29 $this->assertFalse($view->getTitle());
32 // Tests a valid user.
33 $account = $this->drupalCreateUser();
34 $this->executeView($view, [$account->id()]);
35 $this->assertEqual($view->getTitle(), $account->label());
38 // Tests the anonymous user.
39 $anonymous = $this->config('user.settings')->get('anonymous');
40 $this->executeView($view, [0]);
41 $this->assertEqual($view->getTitle(), $anonymous);
44 $view->getDisplay()->getHandler('argument', 'uid')->options['break_phrase'] = TRUE;
45 $this->executeView($view, [$account->id() . ',0']);
46 $this->assertEqual($view->getTitle(), $account->label() . ', ' . $anonymous);
49 $view->getDisplay()->getHandler('argument', 'uid')->options['break_phrase'] = TRUE;
50 $this->executeView($view, ['0,' . $account->id()]);
51 $this->assertEqual($view->getTitle(), $anonymous . ', ' . $account->label());