Problem/Motivation

All kernel tests are PHPUnit tests and therefore must live in tests/src/Kernel, not in the old Simpletest location src/Tests.

modules/system/src/Tests/Common/SystemListingTest.php:13:class SystemListingTest extends KernelTestBase {
modules/system/src/Tests/Common/PageRenderTest.php:12:class PageRenderTest extends KernelTestBase {
modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php:22:abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
modules/system/src/Tests/Entity/EntityUnitTestBase.php:16:abstract class EntityUnitTestBase extends KernelTestBase {
modules/views/src/Tests/ViewKernelTestBase.php:20:abstract class ViewKernelTestBase extends KernelTestBase {
modules/simpletest/src/Tests/KernelTestBaseTest.php:16:class KernelTestBaseTest extends KernelTestBase {
modules/serialization/src/Tests/NormalizerTestBase.php:9:abstract class NormalizerTestBase extends KernelTestBase {

Proposed resolution

Move the kernel tests to their correct location. Keep base classes at their old location, but deprecate them.

Remaining tasks

Patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

klausi created an issue. See original summary.

klausi’s picture

Status: Active » Needs review
FileSize
5.55 KB

Patch. The remaining files are all base classes that all have an @deprecated tag now:

ag --file-search-regex '/src/Tests' 'extends KernelTestBase'
core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php:22:abstract class GenericCacheBackendUnitTestBase extends KernelTestBase {
core/modules/system/src/Tests/Entity/EntityUnitTestBase.php:16:abstract class EntityUnitTestBase extends KernelTestBase {
core/modules/views/src/Tests/ViewKernelTestBase.php:20:abstract class ViewKernelTestBase extends KernelTestBase {
core/modules/serialization/src/Tests/NormalizerTestBase.php:16:abstract class NormalizerTestBase extends KernelTestBase {
klausi’s picture

FileSize
5.53 KB

Oops, fixed 1 @deprecated comment.

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Looks good

dawehner’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/src/Tests/Plugin/PluginKernelTestBase.php
diff --git a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseSystemTest.php
similarity index 99%

similarity index 99%
rename from core/modules/simpletest/src/Tests/KernelTestBaseTest.php

rename from core/modules/simpletest/src/Tests/KernelTestBaseTest.php
rename to core/tests/Drupal/KernelTests/KernelTestBaseSystemTest.php

rename to core/tests/Drupal/KernelTests/KernelTestBaseSystemTest.php
index 15ecf1f..ba63013 100644

index 15ecf1f..ba63013 100644
--- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php

--- a/core/modules/simpletest/src/Tests/KernelTestBaseTest.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBaseSystemTest.php

+++ b/core/tests/Drupal/KernelTests/KernelTestBaseSystemTest.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBaseSystemTest.php
@@ -1,6 +1,6 @@

@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\simpletest\Tests;
+namespace Drupal\KernelTests;
 
 use Drupal\Core\Database\Database;
 use Drupal\field\Entity\FieldConfig;
@@ -11,9 +11,9 @@

@@ -11,9 +11,9 @@
 /**
  * Tests KernelTestBase functionality.
  *
- * @group simpletest
+ * @group PHPUnit
  */
-class KernelTestBaseTest extends KernelTestBase {

This move is wrong. This is testing the old kernel test, so it should stay there.

klausi’s picture

Status: Needs work » Needs review
FileSize
4.68 KB
871 bytes

Good catch, I completely forgot about the old kernel test base. Let's remove it in #2734663: Update deprecation message for old KernelTestBase in simpletest.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Looks great now!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 6: kernel-location-2798097-6.patch, failed testing.

klausi’s picture

Status: Needs work » Reviewed & tested by the community

Random test fail, back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/serialization/src/Tests/NormalizerTestBase.php
@@ -6,6 +6,12 @@
+/**
+ * Helper base class to set up some test fields for serialization testing.
+ *
+ * @deprecated Scheduled for removal in Drupal 9.0.0.
+ *   Use \Drupal\Tests\serialization\Kernel\NormalizerTestBase instead.
+ */
 abstract class NormalizerTestBase extends KernelTestBase {

Can this extend from the new class so we are not maintaining duplicate code?

claudiu.cristea’s picture

Status: Needs work » Needs review
FileSize
5.97 KB
1.98 KB

Addressing #10.

naveenvalecha’s picture

Status: Needs review » Reviewed & tested by the community

looks good to go.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +rc eligible

As this is only touching tests and leave the base test classes in place and deprecated committed to 8.2.x as well as 8.3.x.

Committed and pushed 0fe04b1 to 8.3.x and 6a8aa90 to 8.2.x. Thanks!

  • alexpott committed 0fe04b1 on 8.3.x
    Issue #2798097 by klausi, claudiu.cristea: Move all kernel tests to...

  • alexpott committed 6a8aa90 on 8.2.x
    Issue #2798097 by klausi, claudiu.cristea: Move all kernel tests to...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.