View source
<?php
namespace Drupal\Tests\xmlsitemap\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\Entity\Role;
class XmlSitemapMultilingualNodeTest extends XmlSitemapMultilingualTestBase {
public static $modules = [
'config_translation',
];
protected function setUp() {
parent::setUp();
$this->admin_user = $this
->drupalCreateUser([
'administer nodes',
'administer languages',
'administer content types',
'access administration pages',
'create page content',
'edit own page content',
]);
$this
->drupalLogin($this->admin_user);
xmlsitemap_link_bundle_enable('node', 'article');
xmlsitemap_link_bundle_enable('node', 'page');
$user_role = Role::load(AccountInterface::ANONYMOUS_ROLE);
$user_role
->grantPermission('access content');
$user_role
->save();
$edit = [
'language_configuration[language_alterable]' => TRUE,
];
$this
->drupalPostForm('admin/structure/types/manage/page', $edit, 'Save content type');
$this
->assertSession()
->responseContains((string) new FormattableMarkup('The content type %content_type has been updated.', [
'%content_type' => 'Basic page',
]));
}
public function testNodeLanguageData() {
$this
->drupalLogin($this->admin_user);
$node = $this
->drupalCreateNode([]);
$this
->drupalPostForm('node/' . $node
->id() . '/edit', [
'langcode[0][value]' => 'en',
], t('Save'));
$link = $this
->assertSitemapLink('node', $node
->id(), [
'status' => 0,
'access' => 1,
]);
$this
->assertSame('en', $link['language']);
$this
->drupalPostForm('node/' . $node
->id() . '/edit', [
'langcode[0][value]' => 'fr',
], t('Save'));
$link = $this
->assertSitemapLink('node', $node
->id(), [
'status' => 0,
'access' => 1,
]);
$this
->assertSame('fr', $link['language']);
}
}