db backup prior to drupal security update
[yaffs-website] / web / core / modules / tracker / src / Tests / Views / TrackerUserUidTest.php
1 <?php
2
3 namespace Drupal\tracker\Tests\Views;
4
5 use Drupal\views\Views;
6
7 /**
8  * Tests the tracker user uid handlers.
9  *
10  * @group tracker
11  */
12 class TrackerUserUidTest extends TrackerTestBase {
13
14   /**
15    * Views used by this test.
16    *
17    * @var array
18    */
19   public static $testViews = ['test_tracker_user_uid'];
20
21   /**
22    * Tests the user uid filter and argument.
23    */
24   public function testUserUid() {
25     $map = [
26       'nid' => 'nid',
27       'title' => 'title',
28     ];
29
30     $expected = [
31       [
32         'nid' => $this->node->id(),
33         'title' => $this->node->label(),
34       ]
35     ];
36
37     $view = Views::getView('test_tracker_user_uid');
38     $this->executeView($view);
39
40     // We should have no results as the filter is set for uid 0.
41     $this->assertIdenticalResultSet($view, [], $map);
42     $view->destroy();
43
44     // Change the filter value to our user.
45     $view->initHandlers();
46     $view->filter['uid_touch_tracker']->value = $this->node->getOwnerId();
47     $this->executeView($view);
48
49     // We should have one result as the filter is set for the created user.
50     $this->assertIdenticalResultSet($view, $expected, $map);
51     $view->destroy();
52
53     // Remove the filter now, so only the argument will affect the query.
54     $view->removeHandler('default', 'filter', 'uid_touch_tracker');
55
56     // Test the incorrect argument UID.
57     $view->initHandlers();
58     $this->executeView($view, [rand()]);
59     $this->assertIdenticalResultSet($view, [], $map);
60     $view->destroy();
61
62     // Test the correct argument UID.
63     $view->initHandlers();
64     $this->executeView($view, [$this->node->getOwnerId()]);
65     $this->assertIdenticalResultSet($view, $expected, $map);
66   }
67
68 }