LanguageAccessSimpleSitemapTest.php in Language access 8
File
tests/src/Functional/LanguageAccessSimpleSitemapTest.php
View source
<?php
namespace Drupal\Tests\language_access\Functional;
use Drupal\simple_sitemap\Queue\QueueWorker;
use Drupal\user\Entity\Role;
class LanguageAccessSimpleSitemapTest extends LanguageAccessTestBase {
protected static $modules = [
'simple_sitemap',
];
protected $generator;
protected function setUp() : void {
parent::setUp();
$this->generator = $this->container
->get('simple_sitemap.generator');
$this->generator
->setBundleSettings('node', 'page', [
'index' => TRUE,
'priority' => 0.5,
'changefreq' => 'hourly',
]);
}
public function testSimpleSitemap() {
$this->generator
->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
$this
->drupalGet('sitemap.xml');
$this
->assertSession()
->responseContains('/test-en');
$this
->assertSession()
->responseNotContains('/test-nl');
$anonymous_role = Role::load('anonymous');
$anonymous_role
->revokePermission('access language en');
$anonymous_role
->grantPermission('access language nl');
$anonymous_role
->save();
$this->generator
->generateSitemap(QueueWorker::GENERATE_TYPE_BACKEND);
$this
->drupalGet('sitemap.xml');
$this
->assertSession()
->responseContains('/test-nl');
$this
->assertSession()
->responseNotContains('/test-en');
}
}