You are here

public function PathautoKernelTest::testSameTitleDifferentLanguages in Pathauto 8

Test potential conflicts with the same alias in different languages.

File

tests/src/Kernel/PathautoKernelTest.php, line 168

Class

PathautoKernelTest
Unit tests for Pathauto functions.

Namespace

Drupal\Tests\pathauto\Kernel

Code

public function testSameTitleDifferentLanguages() {

  // Create two English articles with the same title.
  $edit = [
    'title' => 'Sample page',
    'type' => 'page',
    'langcode' => 'en',
  ];
  $node1 = $this
    ->drupalCreateNode($edit);
  $this
    ->assertEntityAlias($node1, '/content/sample-page', 'en');
  $node2 = $this
    ->drupalCreateNode($edit);
  $this
    ->assertEntityAlias($node2, '/content/sample-page-0', 'en');

  // Now, create a French article with the same title, and verify that it gets
  // the basic alias with the correct langcode.
  $edit['langcode'] = 'fr';
  $node3 = $this
    ->drupalCreateNode($edit);
  $this
    ->assertEntityAlias($node3, '/content/sample-page', 'fr');
}