You are here

public function TrackerNodeAccessTest::testTrackerNodeAccessIndexing in Drupal 8

Same name and namespace in other branches
  1. 9 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 43

Class

TrackerNodeAccessTest
Tests for private node access on /tracker.

Namespace

Drupal\Tests\tracker\Functional

Code

public function testTrackerNodeAccessIndexing() {

  // 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' => t('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
    ->assertText($private_node
    ->getTitle());
}