You are here

public function SimplesitemapTest::testAtomicEntityIndexation in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 4.x tests/src/Functional/SimplesitemapTest.php \Drupal\Tests\simple_sitemap\Functional\SimplesitemapTest::testAtomicEntityIndexation()

Test indexing an atomic entity (here: a user)

File

tests/src/Functional/SimplesitemapTest.php, line 486

Class

SimplesitemapTest
Tests Simple XML Sitemap functional integration.

Namespace

Drupal\Tests\simple_sitemap\Functional

Code

public function testAtomicEntityIndexation() {
  $user_id = $this->privilegedUser
    ->id();
  $this->generator
    ->setBundleSettings('user')
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalGet($this->defaultSitemapUrl);
  $this
    ->assertSession()
    ->responseNotContains('user/' . $user_id);
  user_role_grant_permissions('anonymous', [
    'access user profiles',
  ]);
  drupal_flush_all_caches();

  //todo Not pretty.
  $this->generator
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalGet($this->defaultSitemapUrl);
  $this
    ->assertSession()
    ->responseContains('user/' . $user_id);
}