From 6ae83e17664cc5f19809b7c4ced4f00f43257946 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Fri, 6 Jul 2018 12:01:32 +0100
Subject: [PATCH] Issue #2982740 by ApacheEx, Lendude, alexpott: Convert
 \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
 to KernelTestBase

---
 .../InstallationProfileModuleTestsTest.php    | 14 ++++++++++----
 .../OtherInstallationProfileTestsTest.php     |  6 +++---
 .../Kernel}/SystemListingCompatibleTest.php   | 19 ++++++++++++++-----
 3 files changed, 27 insertions(+), 12 deletions(-)
 rename core/profiles/testing/modules/drupal_system_listing_compatible_test/{src/Tests => tests/src/Kernel}/SystemListingCompatibleTest.php (66%)

diff --git a/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php b/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
index 5d9c22926286..7f4948b2e9ad 100644
--- a/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
+++ b/core/modules/simpletest/src/Tests/InstallationProfileModuleTestsTest.php
@@ -35,7 +35,7 @@ class InstallationProfileModuleTestsTest extends WebTestBase {
    * - but still install the drupal_system_listing_compatible_test.module
    *   contained in the Testing profile.
    *
-   * @see \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
+   * @see \Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCompatibleTest
    *
    * @var string
    */
@@ -53,12 +53,18 @@ protected function setUp() {
    */
   public function testInstallationProfileTests() {
     $this->drupalGet('admin/config/development/testing');
-    $this->assertText('Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest');
+    $this->assertText('Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCompatibleTest');
     $edit = [
-      'tests[Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest]' => TRUE,
+      'tests[Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCompatibleTest]' => TRUE,
     ];
     $this->drupalPostForm(NULL, $edit, t('Run tests'));
-    $this->assertText('SystemListingCompatibleTest test executed.');
+
+    // Verifies that tests in installation profile modules are passed.
+    $element = $this->xpath('//tr[contains(@class, :class)]/td[contains(text(), :value)]', [
+      ':class' => 'simpletest-pass',
+      ':value' => 'Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCompatibleTest',
+    ]);
+    $this->assertTrue(!empty($element));
   }
 
 }
diff --git a/core/modules/simpletest/tests/src/Functional/OtherInstallationProfileTestsTest.php b/core/modules/simpletest/tests/src/Functional/OtherInstallationProfileTestsTest.php
index ceb7d57f7285..33229c846385 100644
--- a/core/modules/simpletest/tests/src/Functional/OtherInstallationProfileTestsTest.php
+++ b/core/modules/simpletest/tests/src/Functional/OtherInstallationProfileTestsTest.php
@@ -8,7 +8,7 @@
  * Verifies that tests in other installation profiles are found.
  *
  * @group simpletest
- * @see SimpleTestInstallationProfileModuleTestsTestCase
+ * @see \Drupal\simpletest\Tests\InstallationProfileModuleTestsTest
  */
 class OtherInstallationProfileTestsTest extends BrowserTestBase {
 
@@ -31,7 +31,7 @@ class OtherInstallationProfileTestsTest extends BrowserTestBase {
    * @var string
    *
    * @see \Drupal\simpletest\Tests\InstallationProfileModuleTestsTest
-   * @see \Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest
+   * @see \Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCompatibleTest
    */
   protected $profile = 'minimal';
 
@@ -60,7 +60,7 @@ public function testOtherInstallationProfile() {
 
     // Assert the existence of a test for a module in a different installation
     // profile than the current.
-    $this->assertText('Drupal\drupal_system_listing_compatible_test\Tests\SystemListingCompatibleTest');
+    $this->assertText('Drupal\Tests\drupal_system_listing_compatible_test\Kernel\SystemListingCompatibleTest');
   }
 
 }
diff --git a/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php b/core/profiles/testing/modules/drupal_system_listing_compatible_test/tests/src/Kernel/SystemListingCompatibleTest.php
similarity index 66%
rename from core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php
rename to core/profiles/testing/modules/drupal_system_listing_compatible_test/tests/src/Kernel/SystemListingCompatibleTest.php
index c7da09fe9682..42fddcc9d9f9 100644
--- a/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php
+++ b/core/profiles/testing/modules/drupal_system_listing_compatible_test/tests/src/Kernel/SystemListingCompatibleTest.php
@@ -1,8 +1,8 @@
 <?php
 
-namespace Drupal\drupal_system_listing_compatible_test\Tests;
+namespace Drupal\Tests\drupal_system_listing_compatible_test\Kernel;
 
-use Drupal\simpletest\WebTestBase;
+use Drupal\KernelTests\KernelTestBase;
 
 /**
  * Verifies that tests in installation profile modules are found and may use
@@ -10,7 +10,7 @@
  *
  * @group drupal_system_listing_compatible_test
  */
-class SystemListingCompatibleTest extends WebTestBase {
+class SystemListingCompatibleTest extends KernelTestBase {
 
   /**
    * Attempt to enable a module from the Testing profile.
@@ -28,17 +28,26 @@ class SystemListingCompatibleTest extends WebTestBase {
    * This test needs to use a different installation profile than the test which
    * asserts that this test is found.
    *
-   * @see SimpleTestInstallationProfileModuleTestsTestCase
+   * @see \Drupal\simpletest\Tests\InstallationProfileModuleTestsTest
    *
    * @var string
    */
   protected $profile = 'minimal';
 
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->setInstallProfile($this->profile);
+  }
+
   /**
    * Non-empty test* method required to executed the test case class.
    */
   public function testSystemListing() {
-    $this->pass(__CLASS__ . ' test executed.');
+    $this->assertTrue(TRUE, __CLASS__ . ' test executed.');
   }
 
 }
-- 
GitLab