3 namespace Drupal\Tests\language\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Confirm that paths are not changed on monolingual non-English sites.
12 class LanguagePathMonolingualTest extends BrowserTestBase {
19 public static $modules = ['block', 'language', 'path'];
21 protected function setUp() {
24 // Create and log in user.
25 $web_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer site configuration']);
26 $this->drupalLogin($web_user);
28 // Enable French language.
30 $edit['predefined_langcode'] = 'fr';
31 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
33 // Make French the default language.
35 'site_default_language' => 'fr',
37 $this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration'));
40 $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete'));
42 // Changing the default language causes a container rebuild. Therefore need
43 // to rebuild the container in the test environment.
44 $this->rebuildContainer();
46 // Verify that French is the only language.
47 $this->container->get('language_manager')->reset();
48 $this->assertFalse(\Drupal::languageManager()->isMultilingual(), 'Site is mono-lingual');
49 $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), 'fr', 'French is the default language');
51 // Set language detection to URL.
52 $edit = ['language_interface[enabled][language-url]' => TRUE];
53 $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
54 $this->drupalPlaceBlock('local_actions_block');
58 * Verifies that links do not have language prefixes in them.
60 public function testPageLinks() {
61 // Navigate to 'admin/config' path.
62 $this->drupalGet('admin/config');
64 // Verify that links in this page do not have a 'fr/' prefix.
65 $this->assertNoLinkByHref('/fr/', 'Links do not contain language prefix');
67 // Verify that links in this page can be followed and work.
68 $this->clickLink(t('Languages'));
69 $this->assertResponse(200, 'Clicked link results in a valid page');
70 $this->assertText(t('Add language'), 'Page contains the add language text');