You are here

public function SimplesitemapTest::testLocking 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::testLocking()

Tests locks

File

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

Class

SimplesitemapTest
Tests Simple XML Sitemap functional integration.

Namespace

Drupal\Tests\simple_sitemap\Functional

Code

public function testLocking() {
  $this->generator
    ->removeCustomLinks()
    ->addCustomLink('/node/' . $this->node
    ->id())
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalLogin($this
    ->createUser([
    'administer sitemap settings',
  ]));
  $this
    ->drupalGet('/admin/config/search/simplesitemap/settings');
  $this
    ->submitForm([
    'simple_sitemap_regenerate_now' => TRUE,
  ], 'Save configuration');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');
  $this
    ->assertSession()
    ->pageTextNotContains('Unable to acquire a lock for sitemap generation.');
  \Drupal::lock()
    ->acquire(QueueWorker::LOCK_ID);
  $this
    ->submitForm([
    'simple_sitemap_regenerate_now' => TRUE,
  ], 'Save configuration');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');
  $this
    ->assertSession()
    ->pageTextContainsOnce('Unable to acquire a lock for sitemap generation.');
}