diff --git a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php index 10664da..18e674c 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationSettingsTest.php @@ -182,6 +182,24 @@ function testSettingsUI() { $this->assertEqual($definitions['body']->isTranslatable(), $translatable, 'Field translatability correctly switched.'); $this->assertEqual($field->isTranslatable(), $definitions['body']->isTranslatable(), 'Configurable field translatability correctly switched.'); } + + // Test that the order of the language list is similar to other language + // lists, such as in Views UI. + $this->drupalGet('admin/config/regional/content-language'); + + $expected_elements = array( + 'site_default', + 'current_interface', + 'authors_default', + 'en', + 'und', + 'zxx', + ); + $elements = $this->xpath('//select[@id="edit-settings-node-article-settings-language-langcode"]/option'); + // Compare values inside the option elements with expected values. + for ($i = 0; $i < count($elements); $i++) { + $this->assertEqual($elements[$i]->attributes()->{'value'}, $expected_elements[$i]); + } } /** diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_display.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_display.yml index 7b8490a..9a0b910 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_display.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_display.yml @@ -39,6 +39,46 @@ display: plugin_id: boolean entity_type: node entity_field: status + langcode: + id: langcode + table: node_field_data + field: langcode + relationship: none + group_type: group + admin_label: '' + operator: in + value: + '***LANGUAGE_language_content***': '***LANGUAGE_language_content***' + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + plugin_id: language + entity_type: node + entity_field: langcode pager: options: items_per_page: 10 diff --git a/core/modules/views_ui/src/Tests/UITestBase.php b/core/modules/views_ui/src/Tests/UITestBase.php index f8cef54..1fe0cec 100644 --- a/core/modules/views_ui/src/Tests/UITestBase.php +++ b/core/modules/views_ui/src/Tests/UITestBase.php @@ -35,6 +35,9 @@ */ public static $modules = array('node', 'views_ui', 'block', 'taxonomy'); + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); @@ -42,7 +45,13 @@ protected function setUp() { $this->adminUser = $this->drupalCreateUser(array('administer views')); - $this->fullAdminUser = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions')); + $this->fullAdminUser = $this->drupalCreateUser(array('administer views', + 'administer blocks', + 'bypass node access', + 'access user profiles', + 'view all revisions', + 'administer permissions', + )); $this->drupalLogin($this->fullAdminUser); } diff --git a/core/modules/views_ui/src/Tests/ViewEditTest.php b/core/modules/views_ui/src/Tests/ViewEditTest.php index d9cd747..4d57245 100644 --- a/core/modules/views_ui/src/Tests/ViewEditTest.php +++ b/core/modules/views_ui/src/Tests/ViewEditTest.php @@ -110,7 +110,7 @@ public function testEditFormLanguageOptions() { } // Make the site multilingual and test the options again. - $this->container->get('module_installer')->install(array('language')); + $this->container->get('module_installer')->install(array('language', 'content_translation')); ConfigurableLanguage::createFromLangcode('hu')->save(); $this->resetAll(); $this->rebuildContainer(); @@ -138,6 +138,73 @@ public function testEditFormLanguageOptions() { } else { $this->assertFieldByName('rendering_language', '***LANGUAGE_entity_translation***'); + // Test that the order of the language list is similar to other language + // lists, such as in Views UI. + $expected_elements = array( + '***LANGUAGE_entity_translation***', + '***LANGUAGE_entity_default***', + '***LANGUAGE_site_default***', + '***LANGUAGE_language_interface***', + 'en', + 'hu', + ); + $elements = $this->xpath('//select[@id="edit-rendering-language"]/option'); + // Compare values inside the option elements with expected values. + for ($i = 0; $i < count($elements); $i++) { + $this->assertEqual($elements[$i]->attributes()->{'value'}, $expected_elements[$i]); + } + + // Check that the selected values are respected even we they are not + // suposed to be listed. + // Give permission to edit languages to authenticated users. + $edit = [ + 'authenticated[administer languages]' => TRUE, + ]; + $this->drupalPostForm('/admin/people/permissions', $edit, t('Save permissions')); + // Enable Content language negotiation so we have one more item + // to select. + $edit = [ + 'language_content[configurable]' => TRUE, + ]; + $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); + + // Choose the new negotiation as the rendering language. + $edit = [ + 'rendering_language' => '***LANGUAGE_language_content***', + ]; + $this->drupalPostForm('/admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language', $edit, t('Apply')); + + // Disable language content negotiation. + $edit = [ + 'language_content[configurable]' => FALSE, + ]; + $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); + + // Check that the previous selection is listed and selected. + $this->drupalGet($langcode_url); + $element = $this->xpath('//select[@id="edit-rendering-language"]/option[@value="***LANGUAGE_language_content***" and @selected="selected"]'); + $this->assertFalse(empty($element), 'Current selection is not lost'); + + // Check the order for the langcode filter. + $langcode_url = 'admin/structure/views/nojs/handler/' . $view_name . '/' . $display . '/filter/langcode'; + $this->drupalGet($langcode_url); + $this->assertResponse(200); + + $expected_elements = array( + 'all', + '***LANGUAGE_site_default***', + '***LANGUAGE_language_interface***', + '***LANGUAGE_language_content***', + 'en', + 'hu', + 'und', + 'zxx', + ); + $elements = $this->xpath('//div[@id="edit-options-value"]//input'); + // Compare values inside the option elements with expected values. + for ($i = 0; $i < count($elements); $i++) { + $this->assertEqual($elements[$i]->attributes()->{'value'}, $expected_elements[$i]); + } } } }