You are here

public function SimpleSitemapViewsTest::testIndexableViews in Simple XML sitemap 8.3

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

Tests indexable views.

File

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

Class

SimpleSitemapViewsTest
Tests Simple XML Sitemap (Views) functional integration.

Namespace

Drupal\Tests\simple_sitemap_views\Functional

Code

public function testIndexableViews() {

  // Ensure that at least one indexable view exists.
  $indexable_views = $this->sitemapViews
    ->getIndexableViews();
  $this
    ->assertNotEmpty($indexable_views);
  $test_view_exists = FALSE;
  foreach ($indexable_views as &$view) {
    if ($view
      ->id() == $this->testView
      ->id() && $view->current_display == $this->testView->current_display) {
      $test_view_exists = TRUE;
      break;
    }
  }

  // The test view should be in the list.
  $this
    ->assertTrue($test_view_exists);

  // Check the indexing status of the arguments.
  $indexable_arguments = $this->sitemapViews
    ->getIndexableArguments($this->testView, $this->sitemapVariant);
  $this
    ->assertContains('type', $indexable_arguments);
  $this
    ->assertContains('title', $indexable_arguments);
  $this
    ->assertNotContains('nid', $indexable_arguments);

  // Check the indexing status of the required arguments.
  $indexable_arguments = $this->sitemapViews
    ->getIndexableArguments($this->testView2, $this->sitemapVariant);
  $this
    ->assertContains('type', $indexable_arguments);
  $this
    ->assertContains('%', $indexable_arguments);
}