Backup of db before drupal security update
[yaffs-website] / web / core / modules / user / src / Tests / Views / HandlerArgumentUserUidTest.php
1 <?php
2
3 namespace Drupal\user\Tests\Views;
4
5 use Drupal\views\Views;
6
7 /**
8  * Tests the handler of the user: uid Argument.
9  *
10  * @group user
11  */
12 class HandlerArgumentUserUidTest extends UserTestBase {
13
14   /**
15    * Views used by this test.
16    *
17    * @var array
18    */
19   public static $testViews = ['test_user_uid_argument'];
20
21   /**
22    * Tests the generated title of an user: uid argument.
23    */
24   public function testArgumentTitle() {
25     $view = Views::getView('test_user_uid_argument');
26
27     // Tests an invalid user uid.
28     $this->executeView($view, [rand(1000, 10000)]);
29     $this->assertFalse($view->getTitle());
30     $view->destroy();
31
32     // Tests a valid user.
33     $account = $this->drupalCreateUser();
34     $this->executeView($view, [$account->id()]);
35     $this->assertEqual($view->getTitle(), $account->label());
36     $view->destroy();
37
38     // Tests the anonymous user.
39     $anonymous = $this->config('user.settings')->get('anonymous');
40     $this->executeView($view, [0]);
41     $this->assertEqual($view->getTitle(), $anonymous);
42     $view->destroy();
43
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);
47     $view->destroy();
48
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());
52     $view->destroy();
53   }
54
55 }