function TrackerNodeAccessTest::testTrackerNodeAccessIndexing

Same name in other branches
  1. 9 core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php \Drupal\Tests\tracker\Functional\TrackerNodeAccessTest::testTrackerNodeAccessIndexing()
  2. 8.9.x core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php \Drupal\Tests\tracker\Functional\TrackerNodeAccessTest::testTrackerNodeAccessIndexing()
  3. 11.x core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php \Drupal\Tests\tracker\Functional\TrackerNodeAccessTest::testTrackerNodeAccessIndexing()

Ensure that tracker_cron is not access sensitive.

File

core/modules/tracker/tests/src/Functional/TrackerNodeAccessTest.php, line 54

Class

TrackerNodeAccessTest
Tests for private node access on /tracker.

Namespace

Drupal\Tests\tracker\Functional

Code

public function testTrackerNodeAccessIndexing() : void {
    // The node is private and not authored by the anonymous user, so any entity
    // queries run for the anonymous user will miss it.
    $author = $this->drupalCreateUser();
    $private_node = $this->drupalCreateNode([
        'title' => 'Private node test',
        'private' => TRUE,
        'uid' => $author->id(),
    ]);
    // Remove index entries, and index as tracker_install() does.
    \Drupal::database()->delete('tracker_node')
        ->execute();
    \Drupal::state()->set('tracker.index_nid', $private_node->id());
    tracker_cron();
    // Test that the private node has been indexed and so can be viewed by a
    // user with node test view permission.
    $user = $this->drupalCreateUser([
        'node test view',
    ]);
    $this->drupalLogin($user);
    $this->drupalGet('activity');
    $this->assertSession()
        ->pageTextContains($private_node->getTitle());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.