You are here

public function SimplesitemapTest::testLinkCount in Simple XML sitemap 4.x

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

Test link count.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

File

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

Class

SimplesitemapTest
Tests Simple XML Sitemap functional integration.

Namespace

Drupal\Tests\simple_sitemap\Functional

Code

public function testLinkCount() {
  $this->generator
    ->entityManager()
    ->setBundleSettings('node', 'page');
  $this->generator
    ->customLinkManager()
    ->remove();
  $this->generator
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalLogin($this
    ->createUser([
    'administer sitemap settings',
  ]));
  $this
    ->drupalGet('admin/config/search/simplesitemap');
  $link_count_elements = $this
    ->xpath('//*[@id="simple-sitemap-status-form"]//table/tbody/tr/td[4]');
  $this
    ->assertSame('2', $link_count_elements[0]
    ->getText());
  $this
    ->createNode([
    'title' => 'Another node',
    'type' => 'page',
  ]);
  $this->generator
    ->entityManager()
    ->setBundleSettings('node', 'page');
  $this->generator
    ->customLinkManager()
    ->remove();
  $this->generator
    ->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
  $this
    ->drupalLogin($this
    ->createUser([
    'administer sitemap settings',
  ]));
  $this
    ->drupalGet('admin/config/search/simplesitemap');
  $link_count_elements = $this
    ->xpath('//*[@id="simple-sitemap-status-form"]//table/tbody/tr/td[4]');
  $this
    ->assertSame('3', $link_count_elements[0]
    ->getText());
}