You are here

public function SimpleSitemapViewsTest::testAddArgumentsToIndex in Simple XML sitemap 4.x

Same name and namespace in other branches
  1. 8.3 modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTest.php \Drupal\Tests\simple_sitemap_views\Functional\SimpleSitemapViewsTest::testAddArgumentsToIndex()

Tests the process of adding arguments to the index.

File

modules/simple_sitemap_views/tests/src/Functional/SimpleSitemapViewsTest.php, line 61

Class

SimpleSitemapViewsTest
Tests Simple XML Sitemap (Views) functional integration.

Namespace

Drupal\Tests\simple_sitemap_views\Functional

Code

public function testAddArgumentsToIndex() {

  // Arguments with the wrong value should not be indexed.
  $this->sitemapViews
    ->addArgumentsToIndex($this->testView, [
    'page2',
  ]);
  $this
    ->assertIndexSize(0);

  // Non-indexable arguments should not be indexed.
  $args = [
    'page',
    $this->node
      ->getTitle(),
    $this->node
      ->id(),
  ];
  $this->sitemapViews
    ->addArgumentsToIndex($this->testView, $args);
  $this
    ->assertIndexSize(0);

  // The argument set should not be indexed more than once.
  for ($i = 0; $i < 2; $i++) {
    $this->sitemapViews
      ->addArgumentsToIndex($this->testView, [
      'page',
    ]);
    $this
      ->assertIndexSize(1);
  }

  // A new set of arguments must be indexed.
  $args = [
    'page',
    $this->node
      ->getTitle(),
  ];
  $this->sitemapViews
    ->addArgumentsToIndex($this->testView, $args);
  $this
    ->assertIndexSize(2);

  // The number of argument sets in the index for one view display should not
  // exceed the maximum number of link variations.
  $args = [
    'page',
    $this->node2
      ->getTitle(),
  ];
  $this->sitemapViews
    ->addArgumentsToIndex($this->testView, $args);
  $this
    ->assertIndexSize(2);

  // Required arguments must be indexed.
  $this->sitemapViews
    ->addArgumentsToIndex($this->testView2, [
    'page',
    1,
  ]);
  $this
    ->assertIndexSize(3);
}