SimplesitemapTest.php in Simple XML sitemap 8
File
src/Tests/SimplesitemapTest.php
View source
<?php
namespace Drupal\simplesitemap\Tests;
use Drupal\simplesitemap\Simplesitemap;
use Drupal\simpletest\WebTestBase;
class SimplesitemapTest extends WebTestBase {
protected $dumpHeaders = TRUE;
protected $strictConfigSchema = FALSE;
public static $modules = [
'simplesitemap',
'node',
];
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'page',
]);
$this
->config('simplesitemap.settings')
->set('entity_types', [
'node_type' => [
'page' => [
'index' => 1,
'priority' => '0.5',
],
],
])
->save();
}
public function testSimplesitemap() {
$sitemap = new Simplesitemap();
$sitemap
->generate_sitemap();
$this
->drupalGet('sitemap.xml');
$this
->assertEqual($this
->drupalGetHeader('X-Drupal-Cache'), 'MISS');
$this
->drupalGet('sitemap.xml');
$this
->assertEqual($this
->drupalGetHeader('X-Drupal-Cache'), 'HIT');
$node = $this
->createNode([
'title' => 'A new page',
]);
$sitemap
->generate_sitemap();
$this
->drupalGet('sitemap.xml');
$this
->assertEqual($this
->drupalGetHeader('X-Drupal-Cache'), 'MISS');
$this
->assertText('node/' . $node
->id());
$this
->drupalGet('sitemap.xml');
$this
->assertEqual($this
->drupalGetHeader('X-Drupal-Cache'), 'HIT');
$this
->assertText('node/' . $node
->id());
}
}