reverted: --- b/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php +++ a/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php @@ -18,17 +18,10 @@ $this->drupalLogin($admin_user); $this->drupalPostForm('admin/config/regional/language/add', array('predefined_langcode' => 'hu'), t('Add language')); $this->drupalGet('admin/structure/block/add/system_menu_block:admin/stark'); + $this->assertNoFieldByXPath('//input[@id="edit-visibility-language-langcodes-und"]', NULL, '\'Not specified\' option does not appear at block config, language settings section.'); + $this->assertNoFieldByXpath('//input[@id="edit-visibility-language-langcodes-zxx"]', NULL, '\'Not applicable\' option does not appear at block config, language settings section.'); + $this->assertFieldByXPath('//input[@id="edit-visibility-language-langcodes-en"]', NULL, '\'English\' option appears at block config, language settings section.'); + $this->assertFieldByXpath('//input[@id="edit-visibility-language-langcodes-hu"]', NULL, '\'Hungarian\' option appears at block config, language settings section.'); - - // 'Not specified' option does not appear at block config, language settings - // section. - $this->assertSession()->fieldNotExists('edit-visibility-language-langcodes-und'); - // 'Not applicable' option does not appear. - $this->assertSession()->fieldNotExists('edit-visibility-language-langcodes-zxx'); - - // // 'English' option appears.. - $this->assertSession()->fieldExists('edit-visibility-language-langcodes-en'); - // // 'Hungarian' option appears.. - $this->assertSession()->fieldExists('edit-visibility-language-langcodes-hu'); } } diff -u b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php --- b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php +++ b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php @@ -5,8 +5,8 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\language\Entity\ContentLanguageSettings; -use Drupal\Tests\BrowserTestBase; use Drupal\taxonomy\Entity\Vocabulary; +use Drupal\Tests\BrowserTestBase; /** * Tests the features of the language configuration element field. diff -u b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php --- b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php @@ -34,13 +34,11 @@ // Check if the Default English language has no path prefix. $this->drupalGet('admin/config/regional/language/detection/url'); - // Default English has no path prefix. - $this->assertSession()->fieldValueEquals('prefix[en]', ''); + $this->assertFieldByXPath('//input[@name="prefix[en]"]', '', 'Default English has no path prefix.'); // Check that Add language is a primary button. $this->drupalGet('admin/config/regional/language/add'); - $button = $this->assertSession()->buttonExists('Add language'); - $this->assertTrue($button->hasClass('button--primary')); + $this->assertFieldByXPath('//input[contains(@class, "button--primary")]', 'Add language', 'Add language is a primary button'); // Add predefined language. $edit = array( @@ -55,10 +53,10 @@ // Check if the Default English language has no path prefix. $this->drupalGet('admin/config/regional/language/detection/url'); - $this->assertSession()->fieldValueEquals('prefix[en]', ''); + $this->assertFieldByXPath('//input[@name="prefix[en]"]', '', 'Default English has no path prefix.'); // Check if French has a path prefix. $this->drupalGet('admin/config/regional/language/detection/url'); - $this->assertSession()->fieldValueEquals('prefix[fr]', 'fr'); + $this->assertFieldByXPath('//input[@name="prefix[fr]"]', 'fr', 'French has a path prefix.'); // Check if we can change the default language. $this->drupalGet('admin/config/regional/language'); @@ -76,17 +74,17 @@ // Check if a valid language prefix is added after changing the default // language. $this->drupalGet('admin/config/regional/language/detection/url'); - $this->assertSession()->fieldValueEquals('prefix[en]', 'en'); + $this->assertFieldByXPath('//input[@name="prefix[en]"]', 'en', 'A valid path prefix has been added to the previous default language.'); // Check if French still has a path prefix. $this->drupalGet('admin/config/regional/language/detection/url'); - $this->assertSession()->fieldValueEquals('prefix[fr]', 'fr'); + $this->assertFieldByXPath('//input[@name="prefix[fr]"]', 'fr', 'French still has a path prefix.'); // Check that prefix can be changed. $edit = array( 'prefix[fr]' => 'french', ); $this->drupalPostForm(NULL, $edit, t('Save configuration')); - $this->assertSession()->fieldValueEquals('prefix[fr]', 'french'); + $this->assertFieldByXPath('//input[@name="prefix[fr]"]', 'french', 'French path prefix has changed.'); // Check that the prefix can be removed. $edit = array( @@ -171,7 +169,10 @@ $this->checkConfigurableLanguageWeight('after re-ordering'); // Remove predefined language. - $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), 'Delete'); + $edit = array( + 'confirm' => 1, + ); + $this->drupalPostForm('admin/config/regional/language/delete/fr', $edit, 'Delete'); $this->checkConfigurableLanguageWeight('after deleting a language'); } diff -u b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php --- b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php @@ -2,9 +2,9 @@ namespace Drupal\Tests\language\Functional; -use Drupal\Tests\BrowserTestBase; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; +use Drupal\Tests\BrowserTestBase; /** * Adds and configures custom languages. diff -u b/core/modules/language/tests/src/Functional/LanguageListTest.php b/core/modules/language/tests/src/Functional/LanguageListTest.php --- b/core/modules/language/tests/src/Functional/LanguageListTest.php +++ b/core/modules/language/tests/src/Functional/LanguageListTest.php @@ -3,9 +3,9 @@ namespace Drupal\Tests\language\Functional; use Drupal\language\Entity\ConfigurableLanguage; -use Drupal\Tests\BrowserTestBase; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; +use Drupal\Tests\BrowserTestBase; /** * Adds a new language and tests changing its status and the default language. @@ -177,14 +177,10 @@ // Ensure that NL cannot be set default when it's not available. $this->drupalGet('admin/config/regional/language'); - try { - $this->drupalPostForm(NULL, array('site_default_language' => 'nl'), t('Save configuration')); - $this->fail('Form validation InvalidArgumentException thrown but not caught.'); - } - catch (\InvalidArgumentException $e) { - $this->assertEquals($e->getMessage(), 'Input "site_default_language" cannot take "nl" as a value (possible values: xx).'); - } - $this->assertFieldChecked('edit-site-default-language-xx', 'The previous default language still selected.'); + $extra_values = '&site_default_language=nl'; + $this->drupalPostForm(NULL, array(), t('Save configuration'), array(), array(), NULL, $extra_values); + $this->assertText(t('Selected default language no longer exists.')); + $this->assertNoFieldChecked('edit-site-default-language-xx', 'The previous default language got deselected.'); } /** diff -u b/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php b/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php --- b/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php +++ b/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php @@ -57,11 +57,9 @@ // 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(); - } + $select = $this->xpath('//select[@id="edit-predefined-langcode"]'); + $select_element = (array) end($select); + $options = $select_element['option']; // Remove the 'Custom language...' option form the end. array_pop($options); // Order language list. diff -u b/core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php b/core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php --- b/core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php +++ b/core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php @@ -82,7 +82,7 @@ $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => 'edit-settings-user-user-settings-language-langcode', ':option' => 'en')); // Check that the language text is translated. - $this->assertEqual($elements[0]->getText(), $name_translation, 'Checking the option string English is translated to Spanish.'); + $this->assertEqual((string) $elements[0], $name_translation, 'Checking the option string English is translated to Spanish.'); } } diff -u b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php --- b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php +++ b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php @@ -73,24 +73,22 @@ // Assert that each list item and anchor element has the appropriate data- // attributes. - $language_switchers = $this->xpath('//div[@id=:id]/ul/li', array(':id' => 'block-test-language-block')); + list($language_switcher) = $this->xpath('//div[@id=:id]', array(':id' => 'block-test-language-block')); $list_items = array(); $anchors = array(); $labels = array(); - foreach ($language_switchers as $list_item) { - $classes = explode(" ", $list_item->getAttribute('class')); + foreach ($language_switcher->ul->li as $list_item) { + $classes = explode(" ", (string) $list_item['class']); list($langcode) = array_intersect($classes, array('en', 'fr')); $list_items[] = array( 'langcode_class' => $langcode, - 'data-drupal-link-system-path' => $list_item->getAttribute('data-drupal-link-system-path'), + 'data-drupal-link-system-path' => (string) $list_item['data-drupal-link-system-path'], ); - - $link = $list_item->find('xpath', 'a'); $anchors[] = array( - 'hreflang' => $link->getAttribute('hreflang'), - 'data-drupal-link-system-path' => $link->getAttribute('data-drupal-link-system-path'), + 'hreflang' => (string) $list_item->a['hreflang'], + 'data-drupal-link-system-path' => (string) $list_item->a['data-drupal-link-system-path'], ); - $labels[] = $link->getText(); + $labels[] = (string) $list_item->a; } $expected_list_items = array( 0 => array('langcode_class' => 'en', 'data-drupal-link-system-path' => 'user/2'), @@ -126,7 +124,7 @@ $this->assertText($block_label, 'Language switcher block found.'); // Assert that only the current language is marked as active. - $language_switchers = $this->xpath('//div[@id=:id]/ul/li', array(':id' => 'block-test-language-block')); + list($language_switcher) = $this->xpath('//div[@id=:id]', array(':id' => 'block-test-language-block')); $links = array( 'active' => array(), 'inactive' => array(), @@ -136,8 +134,8 @@ 'inactive' => array(), ); $labels = array(); - foreach ($language_switchers as $list_item) { - $classes = explode(" ", $list_item->getAttribute('class')); + foreach ($language_switcher->ul->li as $link) { + $classes = explode(" ", (string) $link['class']); list($langcode) = array_intersect($classes, array('en', 'fr')); if (in_array('is-active', $classes)) { $links['active'][] = $langcode; @@ -145,16 +143,14 @@ else { $links['inactive'][] = $langcode; } - - $link = $list_item->find('xpath', 'a'); - $anchor_classes = explode(" ", $link->getAttribute('class')); + $anchor_classes = explode(" ", (string) $link->a['class']); if (in_array('is-active', $anchor_classes)) { $anchors['active'][] = $langcode; } else { $anchors['inactive'][] = $langcode; } - $labels[] = $link->getText(); + $labels[] = (string) $link->a; } $this->assertIdentical($links, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language list item is marked as active on the language switcher block.'); $this->assertIdentical($anchors, array('active' => array('en'), 'inactive' => array('fr')), 'Only the current language anchor is marked as active on the language switcher block.'); @@ -212,7 +208,7 @@ ':hreflang' => 'en', )); $english_url = $generator->generateFromRoute('entity.user.canonical', array('user' => 2), array('language' => $languages['en'])); - $this->assertEqual($english_url, $english_link->getAttribute('href')); + $this->assertEqual($english_url, (string) $english_link['href']); // Verify the Italian URL is correct list($italian_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', array( @@ -220,7 +216,7 @@ ':hreflang' => 'it', )); $italian_url = $generator->generateFromRoute('entity.user.canonical', array('user' => 2), array('language' => $languages['it'])); - $this->assertEqual($italian_url, $italian_link->getAttribute('href')); + $this->assertEqual($italian_url, (string) $italian_link['href']); } /** diff -u b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php --- b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php @@ -8,9 +8,9 @@ use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSelected; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationSession; use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl; +use Drupal\Tests\BrowserTestBase; use Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUser; use Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin; -use Drupal\Tests\BrowserTestBase; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageInterface; use Symfony\Component\HttpFoundation\Request; @@ -69,9 +69,9 @@ // For testing path prefix. $langcode = 'zh-hans'; // For setting browser language preference to 'vi'. - $http_header_browser_fallback = array("Accept-Language" => "$langcode_browser_fallback;q=1"); + $http_header_browser_fallback = array("Accept-Language: $langcode_browser_fallback;q=1"); // For setting browser language preference to some unknown. - $http_header_blah = array("Accept-Language" => "blah;q=1"); + $http_header_blah = array("Accept-Language: blah;q=1"); // Setup the site languages by installing two languages. // Set the default language in order for the translated string to be registered @@ -107,7 +107,7 @@ ); $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); $textarea = current($this->xpath('//textarea')); - $lid = $textarea->getAttribute('name'); + $lid = (string) $textarea[0]['name']; $edit = array( $lid => $language_browser_fallback_string, ); @@ -119,7 +119,7 @@ ); $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); $textarea = current($this->xpath('//textarea')); - $lid = $textarea->getAttribute('name'); + $lid = (string) $textarea[0]['name']; $edit = array( $lid => $language_string, ); @@ -398,7 +398,7 @@ // Access the front page without specifying any valid URL language prefix // and having as browser language preference a non-default language. - $http_header = array("Accept-Language" => "$langcode_browser_fallback;q=1"); + $http_header = array("Accept-Language: $langcode_browser_fallback;q=1"); $language = new Language(array('id' => '')); $this->drupalGet('', array('language' => $language), $http_header); @@ -406,11 +406,11 @@ // language. $args = array(':id' => 'block-test-language-block', ':url' => \Drupal::url('') . $langcode_browser_fallback); $fields = $this->xpath('//div[@id=:id]//a[@class="language-link is-active" and starts-with(@href, :url)]', $args); - $this->assertSame($fields[0]->getText(), $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language'); + $this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language'); // Check that URLs are rewritten using the given browser language. $fields = $this->xpath('//div[@class="site-name"]/a[@rel="home" and @href=:url]', $args); - $this->assertSame($fields[0]->getText(), 'Drupal', 'URLs are rewritten using the browser language.'); + $this->assertTrue($fields[0] == 'Drupal', 'URLs are rewritten using the browser language.'); } /** diff -u b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php --- b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php @@ -90,8 +90,9 @@ // we can always check the prefixed URL. $prefixes = language_negotiation_url_prefixes(); $stored_prefix = isset($prefixes[$language->getId()]) ? $prefixes[$language->getId()] : $this->randomMachineName(); - $this->assertNotEqual($stored_prefix, $prefix, $message1); - $prefix = $stored_prefix; + if ($this->assertNotEqual($stored_prefix, $prefix, $message1)) { + $prefix = $stored_prefix; + } $this->drupalGet("$prefix/$path"); $this->assertResponse(404, $message2);