From 82fb89c7b893c79ef91b018733ee7930c1ebd932 Mon Sep 17 00:00:00 2001
From: GoZ <goz@226961.no-reply.drupal.org>
Date: Wed, 22 Feb 2017 18:05:37 +0100
Subject: [PATCH] Issue #2756059 by klausi, naveenvalecha: Convert web tests to
 browser tests for language module

---
 .../EntityTypeWithoutLanguageFormTest.php          |  6 ++--
 .../LanguageBlockSettingsVisibilityTest.php        | 15 ++++++---
 .../LanguageConfigurationElementTest.php           |  6 ++--
 .../src/Functional}/LanguageConfigurationTest.php  | 27 ++++++++-------
 .../LanguageCustomLanguageConfigurationTest.php    |  6 ++--
 .../src/Functional}/LanguageListTest.php           | 18 ++++++----
 .../src/Functional}/LanguageLocaleListTest.php     | 14 ++++----
 .../LanguageSelectorTranslatableTest.php           |  8 ++---
 .../src/Functional}/LanguageSwitchingTest.php      | 38 ++++++++++++----------
 .../src/Functional}/LanguageTourTest.php           |  2 +-
 .../LanguageUILanguageNegotiationTest.php          | 20 ++++++------
 .../src/Functional}/LanguageUrlRewritingTest.php   | 11 +++----
 12 files changed, 93 insertions(+), 78 deletions(-)
 rename core/modules/language/{src/Tests => tests/src/Functional}/EntityTypeWithoutLanguageFormTest.php (87%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageConfigurationElementTest.php (98%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageConfigurationTest.php (89%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageCustomLanguageConfigurationTest.php (96%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageListTest.php (94%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageLocaleListTest.php (84%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageSelectorTranslatableTest.php (88%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageSwitchingTest.php (94%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageTourTest.php (96%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageUILanguageNegotiationTest.php (97%)
 rename core/modules/language/{src/Tests => tests/src/Functional}/LanguageUrlRewritingTest.php (96%)

diff --git a/core/modules/language/src/Tests/EntityTypeWithoutLanguageFormTest.php b/core/modules/language/tests/src/Functional/EntityTypeWithoutLanguageFormTest.php
similarity index 87%
rename from core/modules/language/src/Tests/EntityTypeWithoutLanguageFormTest.php
rename to core/modules/language/tests/src/Functional/EntityTypeWithoutLanguageFormTest.php
index 20a3532..14d5473 100644
--- a/core/modules/language/src/Tests/EntityTypeWithoutLanguageFormTest.php
+++ b/core/modules/language/tests/src/Functional/EntityTypeWithoutLanguageFormTest.php
@@ -1,8 +1,8 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 
 /**
  * Tests entity type without language support.
@@ -12,7 +12,7 @@
  *
  * @group language
  */
-class EntityTypeWithoutLanguageFormTest extends WebTestBase {
+class EntityTypeWithoutLanguageFormTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
diff --git a/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php b/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php
index 3090d5b..601da4d 100644
--- a/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageBlockSettingsVisibilityTest.php
@@ -18,10 +18,17 @@ public function testUnnecessaryLanguageSettingsVisibility() {
     $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 --git a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php
similarity index 98%
rename from core/modules/language/src/Tests/LanguageConfigurationElementTest.php
rename to core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php
index 93b821d..10d0bfa 100644
--- a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageConfigurationElementTest.php
@@ -1,11 +1,11 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\language\Entity\ContentLanguageSettings;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 use Drupal\taxonomy\Entity\Vocabulary;
 
 /**
@@ -13,7 +13,7 @@
  *
  * @group language
  */
-class LanguageConfigurationElementTest extends WebTestBase {
+class LanguageConfigurationElementTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
diff --git a/core/modules/language/src/Tests/LanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
similarity index 89%
rename from core/modules/language/src/Tests/LanguageConfigurationTest.php
rename to core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
index cf049f1..e53b05e 100644
--- a/core/modules/language/src/Tests/LanguageConfigurationTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageConfigurationTest.php
@@ -1,17 +1,17 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\language\Entity\ConfigurableLanguage;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 
 /**
  * Adds and configures languages to check negotiation changes.
  *
  * @group language
  */
-class LanguageConfigurationTest extends WebTestBase {
+class LanguageConfigurationTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
@@ -34,11 +34,13 @@ function testLanguageConfiguration() {
 
     // Check if the Default English language has no path prefix.
     $this->drupalGet('admin/config/regional/language/detection/url');
-    $this->assertFieldByXPath('//input[@name="prefix[en]"]', '', 'Default English has no path prefix.');
+    // Default English has no path prefix.
+    $this->assertSession()->fieldValueEquals('prefix[en]', '');
 
     // Check that Add language is a primary button.
     $this->drupalGet('admin/config/regional/language/add');
-    $this->assertFieldByXPath('//input[contains(@class, "button--primary")]', 'Add language', 'Add language is a primary button');
+    $button = $this->assertSession()->buttonExists('Add language');
+    $this->assertTrue($button->hasClass('button--primary'));
 
     // Add predefined language.
     $edit = array(
@@ -53,10 +55,10 @@ function testLanguageConfiguration() {
 
     // Check if the Default English language has no path prefix.
     $this->drupalGet('admin/config/regional/language/detection/url');
-    $this->assertFieldByXPath('//input[@name="prefix[en]"]', '', 'Default English has no path prefix.');
+    $this->assertSession()->fieldValueEquals('prefix[en]', '');
     // Check if French has a path prefix.
     $this->drupalGet('admin/config/regional/language/detection/url');
-    $this->assertFieldByXPath('//input[@name="prefix[fr]"]', 'fr', 'French has a path prefix.');
+    $this->assertSession()->fieldValueEquals('prefix[fr]', 'fr');
 
     // Check if we can change the default language.
     $this->drupalGet('admin/config/regional/language');
@@ -74,17 +76,17 @@ function testLanguageConfiguration() {
     // Check if a valid language prefix is added after changing the default
     // language.
     $this->drupalGet('admin/config/regional/language/detection/url');
-    $this->assertFieldByXPath('//input[@name="prefix[en]"]', 'en', 'A valid path prefix has been added to the previous default language.');
+    $this->assertSession()->fieldValueEquals('prefix[en]', 'en');
     // Check if French still has a path prefix.
     $this->drupalGet('admin/config/regional/language/detection/url');
-    $this->assertFieldByXPath('//input[@name="prefix[fr]"]', 'fr', 'French still has a path prefix.');
+    $this->assertSession()->fieldValueEquals('prefix[fr]', 'fr');
 
     // Check that prefix can be changed.
     $edit = array(
       'prefix[fr]' => 'french',
     );
     $this->drupalPostForm(NULL, $edit, t('Save configuration'));
-    $this->assertFieldByXPath('//input[@name="prefix[fr]"]', 'french', 'French path prefix has changed.');
+    $this->assertSession()->fieldValueEquals('prefix[fr]', 'french');
 
     // Check that the prefix can be removed.
     $edit = array(
@@ -169,10 +171,7 @@ function testLanguageConfigurationWeight() {
     $this->checkConfigurableLanguageWeight('after re-ordering');
 
     // Remove predefined language.
-    $edit = array(
-      'confirm' => 1,
-    );
-    $this->drupalPostForm('admin/config/regional/language/delete/fr', $edit, 'Delete');
+    $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), 'Delete');
     $this->checkConfigurableLanguageWeight('after deleting a language');
   }
 
diff --git a/core/modules/language/src/Tests/LanguageCustomLanguageConfigurationTest.php b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php
similarity index 96%
rename from core/modules/language/src/Tests/LanguageCustomLanguageConfigurationTest.php
rename to core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php
index dbd35cd..6c01c00 100644
--- a/core/modules/language/src/Tests/LanguageCustomLanguageConfigurationTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageCustomLanguageConfigurationTest.php
@@ -1,8 +1,8 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Language\LanguageInterface;
 
@@ -11,7 +11,7 @@
  *
  * @group language
  */
-class LanguageCustomLanguageConfigurationTest extends WebTestBase {
+class LanguageCustomLanguageConfigurationTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
diff --git a/core/modules/language/src/Tests/LanguageListTest.php b/core/modules/language/tests/src/Functional/LanguageListTest.php
similarity index 94%
rename from core/modules/language/src/Tests/LanguageListTest.php
rename to core/modules/language/tests/src/Functional/LanguageListTest.php
index d407530..33c881b 100644
--- a/core/modules/language/src/Tests/LanguageListTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageListTest.php
@@ -1,9 +1,9 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
 use Drupal\language\Entity\ConfigurableLanguage;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Language\LanguageInterface;
 
@@ -12,7 +12,7 @@
  *
  * @group language
  */
-class LanguageListTest extends WebTestBase {
+class LanguageListTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
@@ -177,10 +177,14 @@ function testLanguageList() {
 
     // Ensure that NL cannot be set default when it's not available.
     $this->drupalGet('admin/config/regional/language');
-    $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.');
+    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.');
   }
 
   /**
diff --git a/core/modules/language/src/Tests/LanguageLocaleListTest.php b/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php
similarity index 84%
rename from core/modules/language/src/Tests/LanguageLocaleListTest.php
rename to core/modules/language/tests/src/Functional/LanguageLocaleListTest.php
index dd3e02a..5ab3662 100644
--- a/core/modules/language/src/Tests/LanguageLocaleListTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageLocaleListTest.php
@@ -1,15 +1,15 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 
 /**
  * Adds a new language with translations and tests language list order.
  *
  * @group language
  */
-class LanguageLocaleListTest extends WebTestBase {
+class LanguageLocaleListTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
@@ -57,9 +57,11 @@ function testLanguageLocaleList() {
 
     // Get language list displayed in select list.
     $this->drupalGet('fr/admin/config/regional/language/add');
-    $select = $this->xpath('//select[@id="edit-predefined-langcode"]');
-    $select_element = (array) end($select);
-    $options = $select_element['option'];
+    $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.
diff --git a/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php b/core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php
similarity index 88%
rename from core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php
rename to core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php
index 84d6779..8f2b5e0 100644
--- a/core/modules/language/src/Tests/LanguageSelectorTranslatableTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageSelectorTranslatableTest.php
@@ -1,15 +1,15 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 
 /**
  * Tests the content translation settings language selector options.
  *
  * @group language
  */
-class LanguageSelectorTranslatableTest extends WebTestBase {
+class LanguageSelectorTranslatableTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
@@ -82,7 +82,7 @@ public function testLanguageStringSelector() {
     $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((string) $elements[0], $name_translation, 'Checking the option string English is translated to Spanish.');
+    $this->assertEqual($elements[0]->getText(), $name_translation, 'Checking the option string English is translated to Spanish.');
   }
 
 }
diff --git a/core/modules/language/src/Tests/LanguageSwitchingTest.php b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
similarity index 94%
rename from core/modules/language/src/Tests/LanguageSwitchingTest.php
rename to core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
index 5d4469d..f377fb8 100644
--- a/core/modules/language/src/Tests/LanguageSwitchingTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
@@ -1,19 +1,19 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
 use Drupal\menu_link_content\Entity\MenuLinkContent;
 use Drupal\Core\Language\LanguageInterface;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 
 /**
  * Functional tests for the language switching feature.
  *
  * @group language
  */
-class LanguageSwitchingTest extends WebTestBase {
+class LanguageSwitchingTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
@@ -73,22 +73,24 @@ protected function doTestLanguageBlockAuthenticated($block_label) {
 
     // Assert that each list item and anchor element has the appropriate data-
     // attributes.
-    list($language_switcher) = $this->xpath('//div[@id=:id]', array(':id' => 'block-test-language-block'));
+    $language_switchers = $this->xpath('//div[@id=:id]/ul/li', array(':id' => 'block-test-language-block'));
     $list_items = array();
     $anchors = array();
     $labels = array();
-    foreach ($language_switcher->ul->li as $list_item) {
-      $classes = explode(" ", (string) $list_item['class']);
+    foreach ($language_switchers as $list_item) {
+      $classes = explode(" ", $list_item->getAttribute('class'));
       list($langcode) = array_intersect($classes, array('en', 'fr'));
       $list_items[] = array(
         'langcode_class' => $langcode,
-        'data-drupal-link-system-path' => (string) $list_item['data-drupal-link-system-path'],
+        'data-drupal-link-system-path' => $list_item->getAttribute('data-drupal-link-system-path'),
       );
+
+      $link = $list_item->find('xpath', 'a');
       $anchors[] = array(
-        'hreflang' => (string) $list_item->a['hreflang'],
-        'data-drupal-link-system-path' => (string) $list_item->a['data-drupal-link-system-path'],
+        'hreflang' => $link->getAttribute('hreflang'),
+        'data-drupal-link-system-path' => $link->getAttribute('data-drupal-link-system-path'),
       );
-      $labels[] = (string) $list_item->a;
+      $labels[] = $link->getText();
     }
     $expected_list_items = array(
       0 => array('langcode_class' => 'en', 'data-drupal-link-system-path' => 'user/2'),
@@ -124,7 +126,7 @@ protected function doTestLanguageBlockAnonymous($block_label) {
     $this->assertText($block_label, 'Language switcher block found.');
 
     // Assert that only the current language is marked as active.
-    list($language_switcher) = $this->xpath('//div[@id=:id]', array(':id' => 'block-test-language-block'));
+    $language_switchers = $this->xpath('//div[@id=:id]/ul/li', array(':id' => 'block-test-language-block'));
     $links = array(
       'active' => array(),
       'inactive' => array(),
@@ -134,8 +136,8 @@ protected function doTestLanguageBlockAnonymous($block_label) {
       'inactive' => array(),
     );
     $labels = array();
-    foreach ($language_switcher->ul->li as $link) {
-      $classes = explode(" ", (string) $link['class']);
+    foreach ($language_switchers as $list_item) {
+      $classes = explode(" ", $list_item->getAttribute('class'));
       list($langcode) = array_intersect($classes, array('en', 'fr'));
       if (in_array('is-active', $classes)) {
         $links['active'][] = $langcode;
@@ -143,14 +145,16 @@ protected function doTestLanguageBlockAnonymous($block_label) {
       else {
         $links['inactive'][] = $langcode;
       }
-      $anchor_classes = explode(" ", (string) $link->a['class']);
+
+      $link = $list_item->find('xpath', 'a');
+      $anchor_classes = explode(" ", $link->getAttribute('class'));
       if (in_array('is-active', $anchor_classes)) {
         $anchors['active'][] = $langcode;
       }
       else {
         $anchors['inactive'][] = $langcode;
       }
-      $labels[] = (string) $link->a;
+      $labels[] = $link->getText();
     }
     $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.');
@@ -208,7 +212,7 @@ function testLanguageBlockWithDomain() {
       ':hreflang' => 'en',
     ));
     $english_url = $generator->generateFromRoute('entity.user.canonical', array('user' => 2), array('language' => $languages['en']));
-    $this->assertEqual($english_url, (string) $english_link['href']);
+    $this->assertEqual($english_url, $english_link->getAttribute('href'));
 
     // Verify the Italian URL is correct
     list($italian_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', array(
@@ -216,7 +220,7 @@ function testLanguageBlockWithDomain() {
       ':hreflang' => 'it',
     ));
     $italian_url = $generator->generateFromRoute('entity.user.canonical', array('user' => 2), array('language' => $languages['it']));
-    $this->assertEqual($italian_url, (string) $italian_link['href']);
+    $this->assertEqual($italian_url, $italian_link->getAttribute('href'));
   }
 
   /**
diff --git a/core/modules/language/src/Tests/LanguageTourTest.php b/core/modules/language/tests/src/Functional/LanguageTourTest.php
similarity index 96%
rename from core/modules/language/src/Tests/LanguageTourTest.php
rename to core/modules/language/tests/src/Functional/LanguageTourTest.php
index 7778367..31c1ce2 100644
--- a/core/modules/language/src/Tests/LanguageTourTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageTourTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
 use Drupal\tour\Tests\TourTestBase;
 
diff --git a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
similarity index 97%
rename from core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php
rename to core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
index 03dd8cb..5db3c63 100644
--- a/core/modules/language/src/Tests/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageUILanguageNegotiationTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
 use Drupal\Core\Url;
 use Drupal\language\Entity\ConfigurableLanguage;
@@ -10,7 +10,7 @@
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
 use Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUser;
 use Drupal\user\Plugin\LanguageNegotiation\LanguageNegotiationUserAdmin;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Language\LanguageInterface;
 use Symfony\Component\HttpFoundation\Request;
@@ -37,7 +37,7 @@
  *
  * @group language
  */
-class LanguageUILanguageNegotiationTest extends WebTestBase {
+class LanguageUILanguageNegotiationTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
@@ -69,9 +69,9 @@ function testUILanguageNegotiation() {
     // 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 @@ function testUILanguageNegotiation() {
     );
     $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
     $textarea = current($this->xpath('//textarea'));
-    $lid = (string) $textarea[0]['name'];
+    $lid = $textarea->getAttribute('name');
     $edit = array(
       $lid => $language_browser_fallback_string,
     );
@@ -119,7 +119,7 @@ function testUILanguageNegotiation() {
     );
     $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter'));
     $textarea = current($this->xpath('//textarea'));
-    $lid = (string) $textarea[0]['name'];
+    $lid = $textarea->getAttribute('name');
     $edit = array(
       $lid => $language_string,
     );
@@ -398,7 +398,7 @@ function testUrlLanguageFallback() {
 
     // 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 @@ function testUrlLanguageFallback() {
     // language.
     $args = array(':id' => 'block-test-language-block', ':url' => \Drupal::url('<front>') . $langcode_browser_fallback);
     $fields = $this->xpath('//div[@id=:id]//a[@class="language-link is-active" and starts-with(@href, :url)]', $args);
-    $this->assertTrue($fields[0] == $languages[$langcode_browser_fallback]->getName(), 'The browser language is the URL active language');
+    $this->assertSame($fields[0]->getText(), $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->assertTrue($fields[0] == 'Drupal', 'URLs are rewritten using the browser language.');
+    $this->assertSame($fields[0]->getText(), 'Drupal', 'URLs are rewritten using the browser language.');
   }
 
   /**
diff --git a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php
similarity index 96%
rename from core/modules/language/src/Tests/LanguageUrlRewritingTest.php
rename to core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php
index 5cd80dc..e08eb0a 100644
--- a/core/modules/language/src/Tests/LanguageUrlRewritingTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php
@@ -1,12 +1,12 @@
 <?php
 
-namespace Drupal\language\Tests;
+namespace Drupal\Tests\language\Functional;
 
 use Drupal\Core\Language\Language;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Url;
 use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
@@ -14,7 +14,7 @@
  *
  * @group language
  */
-class LanguageUrlRewritingTest extends WebTestBase {
+class LanguageUrlRewritingTest extends BrowserTestBase {
 
   /**
    * Modules to enable.
@@ -90,9 +90,8 @@ private function checkUrl(LanguageInterface $language, $message1, $message2) {
     // we can always check the prefixed URL.
     $prefixes = language_negotiation_url_prefixes();
     $stored_prefix = isset($prefixes[$language->getId()]) ? $prefixes[$language->getId()] : $this->randomMachineName();
-    if ($this->assertNotEqual($stored_prefix, $prefix, $message1)) {
-      $prefix = $stored_prefix;
-    }
+    $this->assertNotEqual($stored_prefix, $prefix, $message1);
+    $prefix = $stored_prefix;
 
     $this->drupalGet("$prefix/$path");
     $this->assertResponse(404, $message2);
-- 
2.8.1

