You are here

public function XmlSitemapMultilingualNodeTest::testNodeLanguageData in XML sitemap 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/XmlSitemapMultilingualNodeTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapMultilingualNodeTest::testNodeLanguageData()

Test language for sitemap node links.

File

tests/src/Functional/XmlSitemapMultilingualNodeTest.php, line 59

Class

XmlSitemapMultilingualNodeTest
Tests the generation of multilingual nodes.

Namespace

Drupal\Tests\xmlsitemap\Functional

Code

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']);
}