X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fpath%2Ftests%2Fsrc%2FFunctional%2FPathLanguageUiTest.php;h=c76284515b65e570c89f2255c1e8468b00d1f185;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=c2e3276246fa1270448a7c88d10fd578824d7c40;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/path/tests/src/Functional/PathLanguageUiTest.php b/web/core/modules/path/tests/src/Functional/PathLanguageUiTest.php index c2e327624..c76284515 100644 --- a/web/core/modules/path/tests/src/Functional/PathLanguageUiTest.php +++ b/web/core/modules/path/tests/src/Functional/PathLanguageUiTest.php @@ -2,6 +2,8 @@ namespace Drupal\Tests\path\Functional; +use Drupal\Core\Language\LanguageInterface; + /** * Confirm that the Path module user interface works with languages. * @@ -78,4 +80,36 @@ class PathLanguageUiTest extends PathTestBase { $this->assertText(t('Filter aliases'), 'Foreign URL alias works'); } + /** + * Test that language unspecific aliases are shown and saved in the node form. + */ + public function testNotSpecifiedNode() { + // Create test node. + $node = $this->drupalCreateNode(); + + // Create a language-unspecific alias in the admin UI, ensure that is + // displayed and the langcode is not changed when saving. + $edit = [ + 'source' => '/node/' . $node->id(), + 'alias' => '/' . $this->getRandomGenerator()->word(8), + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + ]; + $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save')); + + $this->drupalGet($node->toUrl('edit-form')); + $this->assertSession()->fieldValueEquals('path[0][alias]', $edit['alias']); + $this->drupalPostForm(NULL, [], t('Save')); + + $this->drupalGet('admin/config/search/path'); + $this->assertSession()->pageTextContains('None'); + $this->assertSession()->pageTextNotContains('English'); + + // Create another node, with no alias, to ensure non-language specific + // aliases are loaded correctly. + $node = $this->drupalCreateNode(); + $this->drupalget($node->toUrl('edit-form')); + $this->drupalPostForm(NULL, [], t('Save')); + $this->assertSession()->pageTextNotContains(t('The alias is already in use.')); + } + }