Mercurial > hg > cmmr2012-drupal-site
diff core/modules/path/tests/src/Functional/PathLanguageUiTest.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | c75dbcec494b |
children |
line wrap: on
line diff
--- a/core/modules/path/tests/src/Functional/PathLanguageUiTest.php Thu Feb 28 11:14:44 2019 +0000 +++ b/core/modules/path/tests/src/Functional/PathLanguageUiTest.php Thu Feb 28 13:11:55 2019 +0000 @@ -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 @@ $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.')); + } + }