3 namespace Drupal\Tests\tracker\Functional\Views;
5 use Drupal\views\Views;
8 * Tests the tracker user uid handlers.
12 class TrackerUserUidTest extends TrackerTestBase {
15 * Views used by this test.
19 public static $testViews = ['test_tracker_user_uid'];
22 * Tests the user uid filter and argument.
24 public function testUserUid() {
32 'nid' => $this->node->id(),
33 'title' => $this->node->label(),
37 $view = Views::getView('test_tracker_user_uid');
38 $this->executeView($view);
40 // We should have no results as the filter is set for uid 0.
41 $this->assertIdenticalResultSet($view, [], $map);
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);
49 // We should have one result as the filter is set for the created user.
50 $this->assertIdenticalResultSet($view, $expected, $map);
53 // Remove the filter now, so only the argument will affect the query.
54 $view->removeHandler('default', 'filter', 'uid_touch_tracker');
56 // Test the incorrect argument UID.
57 $view->initHandlers();
58 $this->executeView($view, [rand()]);
59 $this->assertIdenticalResultSet($view, [], $map);
62 // Test the correct argument UID.
63 $view->initHandlers();
64 $this->executeView($view, [$this->node->getOwnerId()]);
65 $this->assertIdenticalResultSet($view, $expected, $map);