You are here

public function SimplesitemapTest::testBatchProcessLimitSetting in Simple XML sitemap 8.2

Test batch process limit setting.

File

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

Class

SimplesitemapTest
Tests Simple XML sitemap functional integration.

Namespace

Drupal\Tests\simple_sitemap\Functional

Code

public function testBatchProcessLimitSetting() {

  // Create some nodes.
  for ($i = 3; $i <= 50; $i++) {
    $this
      ->createNode([
      'title' => "Node{$i}",
      'type' => 'page',
    ]);
  }

  // Test batch_process_limit setting.
  $sitemap = $this->generator
    ->setBundleSettings('node', 'page')
    ->generateSitemap('nobatch')
    ->getSitemap();
  $sitemap2 = $this->generator
    ->saveSetting('batch_process_limit', 1)
    ->generateSitemap('nobatch')
    ->getSitemap();
  $sitemap3 = $this->generator
    ->saveSetting('batch_process_limit', 10)
    ->generateSitemap('nobatch')
    ->getSitemap();
  $this
    ->assertEquals($sitemap2, $sitemap);
  $this
    ->assertEquals($sitemap3, $sitemap);

  // Test batch_process_limit setting in combination with max_links setting.
  $sitemap_index = $this->generator
    ->setBundleSettings('node', 'page')
    ->saveSetting('batch_process_limit', 1500)
    ->saveSetting('max_links', 30)
    ->generateSitemap('nobatch')
    ->getSitemap();
  $sitemap_chunk = $this->generator
    ->getSitemap(1);
  $sitemap_index2 = $this->generator
    ->saveSetting('batch_process_limit', 1)
    ->generateSitemap('nobatch')
    ->getSitemap();
  $sitemap_chunk2 = $this->generator
    ->getSitemap(1);
  $sitemap_index3 = $this->generator
    ->saveSetting('batch_process_limit', 10)
    ->generateSitemap('nobatch')
    ->getSitemap();
  $sitemap_chunk3 = $this->generator
    ->getSitemap(1);
  $this
    ->assertSame($sitemap_index2, $sitemap_index);
  $this
    ->assertSame($sitemap_chunk2, $sitemap_chunk);
  $this
    ->assertSame($sitemap_index3, $sitemap_index);
  $this
    ->assertSame($sitemap_chunk3, $sitemap_chunk);
}