protected function XmlSitemapMultilingualTestBase::setUp in XML sitemap 2.x
Same name and namespace in other branches
- 8 tests/src/Functional/XmlSitemapMultilingualTestBase.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapMultilingualTestBase::setUp()
Set up an administrative user account and testing keys.
Overrides XmlSitemapTestBase::setUp
2 methods override XmlSitemapMultilingualTestBase::setUp()
- XmlSitemapMultilingualNodeTest::setUp in tests/
src/ Functional/ XmlSitemapMultilingualNodeTest.php - Set up an administrative user account and testing keys.
- XmlSitemapMultilingualTest::setUp in tests/
src/ Functional/ XmlSitemapMultilingualTest.php - Set up an administrative user account and testing keys.
File
- tests/
src/ Functional/ XmlSitemapMultilingualTestBase.php, line 21
Class
- XmlSitemapMultilingualTestBase
- Common base test class for XML sitemap internationalization tests.
Namespace
Drupal\Tests\xmlsitemap\FunctionalCode
protected function setUp() {
// Call parent::setUp() allowing test cases to pass further modules.
parent::setUp();
$this->admin_user = $this
->drupalCreateUser([
'administer languages',
'access administration pages',
'administer site configuration',
'administer xmlsitemap',
'access content',
]);
$this
->drupalLogin($this->admin_user);
if (!$this->languageManager
->getLanguage('fr')) {
// Add a new language.
ConfigurableLanguage::createFromLangcode('fr')
->save();
}
if (!$this->languageManager
->getLanguage('en')) {
// Add a new language.
ConfigurableLanguage::createFromLangcode('en')
->save();
}
// Create the two different language-context sitemaps.
$previous_sitemaps = XmlSitemap::loadMultiple();
foreach ($previous_sitemaps as $previous_sitemap) {
$previous_sitemap
->delete();
}
$sitemap = XmlSitemap::create();
$sitemap->context = [
'language' => 'en',
];
xmlsitemap_sitemap_save($sitemap);
$sitemap = XmlSitemap::create();
$sitemap->context = [
'language' => 'fr',
];
xmlsitemap_sitemap_save($sitemap);
}