Mercurial > hg > isophonics-drupal-site
comparison core/modules/language/tests/src/Functional/LanguagePathMonolingualTest.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\language\Functional; | |
4 | |
5 use Drupal\Tests\BrowserTestBase; | |
6 | |
7 /** | |
8 * Confirm that paths are not changed on monolingual non-English sites. | |
9 * | |
10 * @group language | |
11 */ | |
12 class LanguagePathMonolingualTest extends BrowserTestBase { | |
13 | |
14 /** | |
15 * Modules to enable. | |
16 * | |
17 * @var array | |
18 */ | |
19 public static $modules = ['block', 'language', 'path']; | |
20 | |
21 protected function setUp() { | |
22 parent::setUp(); | |
23 | |
24 // Create and log in user. | |
25 $web_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer site configuration']); | |
26 $this->drupalLogin($web_user); | |
27 | |
28 // Enable French language. | |
29 $edit = []; | |
30 $edit['predefined_langcode'] = 'fr'; | |
31 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); | |
32 | |
33 // Make French the default language. | |
34 $edit = [ | |
35 'site_default_language' => 'fr', | |
36 ]; | |
37 $this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration')); | |
38 | |
39 // Delete English. | |
40 $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete')); | |
41 | |
42 // Changing the default language causes a container rebuild. Therefore need | |
43 // to rebuild the container in the test environment. | |
44 $this->rebuildContainer(); | |
45 | |
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'); | |
50 | |
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'); | |
55 } | |
56 | |
57 /** | |
58 * Verifies that links do not have language prefixes in them. | |
59 */ | |
60 public function testPageLinks() { | |
61 // Navigate to 'admin/config' path. | |
62 $this->drupalGet('admin/config'); | |
63 | |
64 // Verify that links in this page do not have a 'fr/' prefix. | |
65 $this->assertNoLinkByHref('/fr/', 'Links do not contain language prefix'); | |
66 | |
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'); | |
71 } | |
72 | |
73 } |