Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\Tests\language\Functional; | 3 namespace Drupal\Tests\language\Functional; |
4 | 4 |
5 use Drupal\Core\Url; | |
5 use Drupal\Core\Language\Language; | 6 use Drupal\Core\Language\Language; |
6 use Drupal\Core\Language\LanguageInterface; | 7 use Drupal\Core\Language\LanguageInterface; |
7 use Drupal\Tests\BrowserTestBase; | 8 use Drupal\Tests\BrowserTestBase; |
8 | 9 |
9 /** | 10 /** |
37 // Test validation on missing values. | 38 // Test validation on missing values. |
38 $this->assertText(t('@name field is required.', ['@name' => t('Language code')])); | 39 $this->assertText(t('@name field is required.', ['@name' => t('Language code')])); |
39 $this->assertText(t('@name field is required.', ['@name' => t('Language name')])); | 40 $this->assertText(t('@name field is required.', ['@name' => t('Language name')])); |
40 $empty_language = new Language(); | 41 $empty_language = new Language(); |
41 $this->assertFieldChecked('edit-direction-' . $empty_language->getDirection(), 'Consistent usage of language direction.'); | 42 $this->assertFieldChecked('edit-direction-' . $empty_language->getDirection(), 'Consistent usage of language direction.'); |
42 $this->assertUrl(\Drupal::url('language.add', [], ['absolute' => TRUE]), [], 'Correct page redirection.'); | 43 $this->assertUrl(Url::fromRoute('language.add', [], ['absolute' => TRUE])->toString(), [], 'Correct page redirection.'); |
43 | 44 |
44 // Test validation of invalid values. | 45 // Test validation of invalid values. |
45 $edit = [ | 46 $edit = [ |
46 'predefined_langcode' => 'custom', | 47 'predefined_langcode' => 'custom', |
47 'langcode' => 'white space', | 48 'langcode' => 'white space', |
54 '%field' => t('Language code'), | 55 '%field' => t('Language code'), |
55 ':url' => 'http://www.w3.org/International/articles/language-tags/', | 56 ':url' => 'http://www.w3.org/International/articles/language-tags/', |
56 ])); | 57 ])); |
57 | 58 |
58 $this->assertRaw(t('%field cannot contain any markup.', ['%field' => t('Language name')])); | 59 $this->assertRaw(t('%field cannot contain any markup.', ['%field' => t('Language name')])); |
59 $this->assertUrl(\Drupal::url('language.add', [], ['absolute' => TRUE]), [], 'Correct page redirection.'); | 60 $this->assertUrl(Url::fromRoute('language.add', [], ['absolute' => TRUE])->toString(), [], 'Correct page redirection.'); |
60 | 61 |
61 // Test adding a custom language with a numeric region code. | 62 // Test adding a custom language with a numeric region code. |
62 $edit = [ | 63 $edit = [ |
63 'predefined_langcode' => 'custom', | 64 'predefined_langcode' => 'custom', |
64 'langcode' => 'es-419', | 65 'langcode' => 'es-419', |
69 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); | 70 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); |
70 $this->assertRaw(t( | 71 $this->assertRaw(t( |
71 'The language %language has been created and can now be used.', | 72 'The language %language has been created and can now be used.', |
72 ['%language' => $edit['label']] | 73 ['%language' => $edit['label']] |
73 )); | 74 )); |
74 $this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.'); | 75 $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE])->toString(), [], 'Correct page redirection.'); |
75 | 76 |
76 // Test validation of existing language values. | 77 // Test validation of existing language values. |
77 $edit = [ | 78 $edit = [ |
78 'predefined_langcode' => 'custom', | 79 'predefined_langcode' => 'custom', |
79 'langcode' => 'de', | 80 'langcode' => 'de', |
85 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); | 86 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); |
86 $this->assertRaw(t( | 87 $this->assertRaw(t( |
87 'The language %language has been created and can now be used.', | 88 'The language %language has been created and can now be used.', |
88 ['%language' => $edit['label']] | 89 ['%language' => $edit['label']] |
89 )); | 90 )); |
90 $this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE]), [], 'Correct page redirection.'); | 91 $this->assertUrl(Url::fromRoute('entity.configurable_language.collection', [], ['absolute' => TRUE])->toString(), [], 'Correct page redirection.'); |
91 | 92 |
92 // Add the language a second time and confirm that this is not allowed. | 93 // Add the language a second time and confirm that this is not allowed. |
93 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); | 94 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); |
94 $this->assertRaw(t( | 95 $this->assertRaw(t( |
95 'The language %language (%langcode) already exists.', | 96 'The language %language (%langcode) already exists.', |
96 ['%language' => $edit['label'], '%langcode' => $edit['langcode']] | 97 ['%language' => $edit['label'], '%langcode' => $edit['langcode']] |
97 )); | 98 )); |
98 $this->assertUrl(\Drupal::url('language.add', [], ['absolute' => TRUE]), [], 'Correct page redirection.'); | 99 $this->assertUrl(Url::fromRoute('language.add', [], ['absolute' => TRUE])->toString(), [], 'Correct page redirection.'); |
99 } | 100 } |
100 | 101 |
101 } | 102 } |