X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Flanguage%2Ftests%2Fsrc%2FFunctional%2FLanguageLocaleListTest.php;fp=web%2Fcore%2Fmodules%2Flanguage%2Ftests%2Fsrc%2FFunctional%2FLanguageLocaleListTest.php;h=a39a1124242b66a3bebcb69b4107218621e7fef1;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php b/web/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php new file mode 100644 index 000000000..a39a11242 --- /dev/null +++ b/web/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php @@ -0,0 +1,75 @@ +storage = $this->container->get('locale.storage'); + } + + /** + * Tests adding, editing, and deleting languages. + */ + public function testLanguageLocaleList() { + // User to add and remove language. + $admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages']); + $this->drupalLogin($admin_user); + + // Add predefined language. + $edit = [ + 'predefined_langcode' => 'fr', + ]; + $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); + $this->assertText('The language French has been created and can now be used'); + $this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE])); + $this->rebuildContainer(); + + // Translate Spanish language to French (Espagnol). + $source = $this->storage->createString([ + 'source' => 'Spanish', + 'context' => '', + ])->save(); + $this->storage->createTranslation([ + 'lid' => $source->lid, + 'language' => 'fr', + 'translation' => 'Espagnol', + ])->save(); + + // Get language list displayed in select list. + $this->drupalGet('fr/admin/config/regional/language/add'); + $option_elements = $this->xpath('//select[@id="edit-predefined-langcode/option"]'); + $options = []; + foreach ($option_elements as $option_element) { + $options[] = $option_element->getText(); + } + // Remove the 'Custom language...' option form the end. + array_pop($options); + // Order language list. + $options_ordered = $options; + natcasesort($options_ordered); + + // Check the language list displayed is ordered. + $this->assertTrue($options === $options_ordered, 'Language list is ordered.'); + } + +}