From 060fccded55d5e882045d4f20e6a2e8fbe216cc2 Mon Sep 17 00:00:00 2001
From: GoZ <goz@226961.no-reply.drupal.org>
Date: Sat, 25 Mar 2017 17:06:19 +0100
Subject: [PATCH] Issue #2864005: Convert web tests to browser tests for
 block_content module

---
 .../src/Functional}/BlockContentCreationTest.php             |  4 ++--
 .../Tests => tests/src/Functional}/BlockContentListTest.php  |  6 +++---
 .../src/Functional}/BlockContentListViewsTest.php            | 12 ++++++------
 .../tests/src/Functional/BlockContentTestBase.php            |  3 +++
 .../src/Functional}/BlockContentTranslationUITest.php        |  2 +-
 .../src/Functional}/BlockContentUpdateTest.php               |  2 +-
 .../src/Functional}/BlockContentValidationTest.php           |  2 +-
 7 files changed, 17 insertions(+), 14 deletions(-)
 rename core/modules/block_content/{src/Tests => tests/src/Functional}/BlockContentCreationTest.php (98%)
 rename core/modules/block_content/{src/Tests => tests/src/Functional}/BlockContentListTest.php (95%)
 rename core/modules/block_content/{src/Tests => tests/src/Functional}/BlockContentListViewsTest.php (91%)
 rename core/modules/block_content/{src/Tests => tests/src/Functional}/BlockContentTranslationUITest.php (99%)
 rename core/modules/block_content/{src/Tests => tests/src/Functional}/BlockContentUpdateTest.php (97%)
 rename core/modules/block_content/{src/Tests => tests/src/Functional}/BlockContentValidationTest.php (96%)

diff --git a/core/modules/block_content/src/Tests/BlockContentCreationTest.php b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
similarity index 98%
rename from core/modules/block_content/src/Tests/BlockContentCreationTest.php
rename to core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
index ac9e824..562a4bd 100644
--- a/core/modules/block_content/src/Tests/BlockContentCreationTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\block_content\Tests;
+namespace Drupal\Tests\block_content\Functional;
 
 use Drupal\block_content\Entity\BlockContent;
 use Drupal\Component\Utility\Unicode;
@@ -140,7 +140,7 @@ public function testBlockContentCreationMultipleViewModes() {
 
     // Go to the configure page and verify the view mode has changed.
     $this->drupalGet('admin/structure/block/manage/testblock');
-    $this->assertFieldByXPath('//select[@name="settings[view_mode]"]/option[@selected="selected"]/@value', 'test_view_mode', 'View mode changed to Test View Mode');
+    $this->assertFieldByXPath('//select[@name="settings[view_mode]"]/option[@selected="selected"]', 'test_view_mode', 'View mode changed to Test View Mode');
 
     // Check that the block exists in the database.
     $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]);
diff --git a/core/modules/block_content/src/Tests/BlockContentListTest.php b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php
similarity index 95%
rename from core/modules/block_content/src/Tests/BlockContentListTest.php
rename to core/modules/block_content/tests/src/Functional/BlockContentListTest.php
index e00706e..aba60c3 100644
--- a/core/modules/block_content/src/Tests/BlockContentListTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentListTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\block_content\Tests;
+namespace Drupal\Tests\block_content\Functional;
 
 /**
  * Tests the listing of custom blocks.
@@ -41,7 +41,7 @@ public function testListing() {
     // Test the contents of each th cell.
     $expected_items = [t('Block description'), t('Operations')];
     foreach ($elements as $key => $element) {
-      $this->assertEqual($element[0], $expected_items[$key]);
+      $this->assertEqual($element->getText(), $expected_items[$key]);
     }
 
     $label = 'Antelope';
@@ -66,7 +66,7 @@ public function testListing() {
     // Check the contents of each row cell. The first cell contains the label,
     // the second contains the machine name, and the third contains the
     // operations list.
-    $this->assertIdentical((string) $elements[0], $label);
+    $this->assertIdentical($elements[0]->getText(), $label);
 
     // Edit the entity using the operations link.
     $blocks = $this->container
diff --git a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php b/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php
similarity index 91%
rename from core/modules/block_content/src/Tests/BlockContentListViewsTest.php
rename to core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php
index 77117fb..1c623be 100644
--- a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentListViewsTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\block_content\Tests;
+namespace Drupal\Tests\block_content\Functional;
 
 /**
  * Tests the Views-powered listing of custom blocks.
@@ -41,13 +41,13 @@ public function testListing() {
     $this->assertEqual(count($elements), 4, 'Correct number of table header cells found.');
 
     // Test the contents of each th cell.
-    $expected_items = ['Block description', 'Block type', 'Updated', 'Operations'];
+    $expected_items = ['Block description', 'Block type', 'Updated Sort ascending', 'Operations'];
     foreach ($elements as $key => $element) {
-      if ($element->xpath('a')) {
-        $this->assertIdentical(trim((string) $element->xpath('a')[0]), $expected_items[$key]);
+      if ($element->find('xpath', 'a')) {
+        $this->assertIdentical(trim($element->find('xpath', 'a')->getText()), $expected_items[$key]);
       }
       else {
-        $this->assertIdentical(trim((string) $element[0]), $expected_items[$key]);
+        $this->assertIdentical(trim($element->getText()), $expected_items[$key]);
       }
     }
 
@@ -73,7 +73,7 @@ public function testListing() {
     // Check the contents of each row cell. The first cell contains the label,
     // the second contains the machine name, and the third contains the
     // operations list.
-    $this->assertIdentical((string) $elements[0]->xpath('a')[0], $label);
+    $this->assertIdentical($elements[0]->find('xpath', 'a')->getText(), $label);
 
     // Edit the entity using the operations link.
     $blocks = $this->container
diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php
index 45c7e26..fef9ec9 100644
--- a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php
@@ -8,6 +8,9 @@
 
 /**
  * Sets up block content types.
+ *
+ * @deprecated Scheduled for removal in Drupal 9.0.0.
+ *   Use \Drupal\Tests\block_content\Functional\BlockContentTestBase instead.
  */
 abstract class BlockContentTestBase extends BrowserTestBase {
 
diff --git a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
similarity index 99%
rename from core/modules/block_content/src/Tests/BlockContentTranslationUITest.php
rename to core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
index 198beee..2699fcf 100644
--- a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\block_content\Tests;
+namespace Drupal\Tests\block_content\Functional;
 
 use Drupal\block_content\Entity\BlockContent;
 use Drupal\block_content\Entity\BlockContentType;
diff --git a/core/modules/block_content/src/Tests/BlockContentUpdateTest.php b/core/modules/block_content/tests/src/Functional/BlockContentUpdateTest.php
similarity index 97%
rename from core/modules/block_content/src/Tests/BlockContentUpdateTest.php
rename to core/modules/block_content/tests/src/Functional/BlockContentUpdateTest.php
index 77c12c6..fcf874d 100644
--- a/core/modules/block_content/src/Tests/BlockContentUpdateTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentUpdateTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\block_content\Tests;
+namespace Drupal\Tests\block_content\Functional;
 
 use Drupal\Core\Field\BaseFieldDefinition;
 use Drupal\system\Tests\Update\UpdatePathTestBase;
diff --git a/core/modules/block_content/src/Tests/BlockContentValidationTest.php b/core/modules/block_content/tests/src/Functional/BlockContentValidationTest.php
similarity index 96%
rename from core/modules/block_content/src/Tests/BlockContentValidationTest.php
rename to core/modules/block_content/tests/src/Functional/BlockContentValidationTest.php
index a0db394..bfa8408 100644
--- a/core/modules/block_content/src/Tests/BlockContentValidationTest.php
+++ b/core/modules/block_content/tests/src/Functional/BlockContentValidationTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\block_content\Tests;
+namespace Drupal\Tests\block_content\Functional;
 
 /**
  * Tests block content validation constraints.
-- 
2.8.1

