diff --git a/.gitlab-ci/pipeline.yml b/.gitlab-ci/pipeline.yml index baabe6af140b11e48d2900cacf4c4bc6b1b25661..3fece5b3ad21deab1748d2113081338fe6081b90 100644 --- a/.gitlab-ci/pipeline.yml +++ b/.gitlab-ci/pipeline.yml @@ -168,10 +168,6 @@ variables: 'âš¡ï¸ PHPUnit Unit': <<: [ *with-composer, *run-tests, *default-job-settings ] - services: - # There are some unit tests that need a database. - # @todo Remove after https://www.drupal.org/project/drupal/issues/3386217 - - <<: *with-database variables: TESTSUITE: PHPUnit-Unit KUBERNETES_CPU_REQUEST: "1" diff --git a/core/tests/Drupal/KernelTests/Components/ComponentInvalidReplacementTest.php b/core/tests/Drupal/KernelTests/Components/ComponentInvalidReplacementTest.php index 4e2f7989b2a89acb64b4d2897ca445ef0c974c41..542c88cc60b70b7dc7dc60c1a66bbf128f2cf9a7 100644 --- a/core/tests/Drupal/KernelTests/Components/ComponentInvalidReplacementTest.php +++ b/core/tests/Drupal/KernelTests/Components/ComponentInvalidReplacementTest.php @@ -5,7 +5,6 @@ namespace Drupal\KernelTests\Components; use Drupal\Core\Render\Component\Exception\IncompatibleComponentSchema; -use Drupal\Tests\Core\Theme\Component\ComponentKernelTestBase; /** * Tests invalid render options for components. diff --git a/core/tests/Drupal/Tests/Core/Theme/Component/ComponentKernelTestBase.php b/core/tests/Drupal/KernelTests/Components/ComponentKernelTestBase.php similarity index 98% rename from core/tests/Drupal/Tests/Core/Theme/Component/ComponentKernelTestBase.php rename to core/tests/Drupal/KernelTests/Components/ComponentKernelTestBase.php index 0c71ae846b9d365547fee9cf62c847574b657f4b..090ba3610604c78ffb52f8ace900a22c69a6c30d 100644 --- a/core/tests/Drupal/Tests/Core/Theme/Component/ComponentKernelTestBase.php +++ b/core/tests/Drupal/KernelTests/Components/ComponentKernelTestBase.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Drupal\Tests\Core\Theme\Component; +namespace Drupal\KernelTests\Components; use Drupal\Core\Render\BubbleableMetadata; use Drupal\Core\Render\RenderContext; diff --git a/core/tests/Drupal/Tests/Core/Theme/Component/ComponentNegotiatorTest.php b/core/tests/Drupal/KernelTests/Components/ComponentNegotiatorTest.php similarity index 97% rename from core/tests/Drupal/Tests/Core/Theme/Component/ComponentNegotiatorTest.php rename to core/tests/Drupal/KernelTests/Components/ComponentNegotiatorTest.php index c2f40242ba959aa76cca6eda0330591cf0b3c3ce..eb38e858f0d2b37f1c8ace7df3ee6152d90cb1f1 100644 --- a/core/tests/Drupal/Tests/Core/Theme/Component/ComponentNegotiatorTest.php +++ b/core/tests/Drupal/KernelTests/Components/ComponentNegotiatorTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Drupal\Tests\Core\Theme\Component; +namespace Drupal\KernelTests\Components; /** * Tests the component negotiator. diff --git a/core/tests/Drupal/KernelTests/Components/ComponentNodeVisitorTest.php b/core/tests/Drupal/KernelTests/Components/ComponentNodeVisitorTest.php index 9a325bd854c7b6d75316eb6b933371968206847c..6b72fa745ea5a354bb58e9c0fed4910c08e71420 100644 --- a/core/tests/Drupal/KernelTests/Components/ComponentNodeVisitorTest.php +++ b/core/tests/Drupal/KernelTests/Components/ComponentNodeVisitorTest.php @@ -4,8 +4,6 @@ namespace Drupal\KernelTests\Components; -use Drupal\Tests\Core\Theme\Component\ComponentKernelTestBase; - /** * Tests the node visitor. * diff --git a/core/tests/Drupal/Tests/Core/Theme/Component/ComponentPluginManagerTest.php b/core/tests/Drupal/KernelTests/Components/ComponentPluginManagerTest.php similarity index 96% rename from core/tests/Drupal/Tests/Core/Theme/Component/ComponentPluginManagerTest.php rename to core/tests/Drupal/KernelTests/Components/ComponentPluginManagerTest.php index b36717f3a24165f6db246dca20aa80cb02089de0..1f110e36b4b5df6aa3e0b2f088680413ab7dd753 100644 --- a/core/tests/Drupal/Tests/Core/Theme/Component/ComponentPluginManagerTest.php +++ b/core/tests/Drupal/KernelTests/Components/ComponentPluginManagerTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Drupal\Tests\Core\Theme\Component; +namespace Drupal\KernelTests\Components; use Drupal\Core\Render\Component\Exception\ComponentNotFoundException; diff --git a/core/tests/Drupal/KernelTests/Components/ComponentRenderInvalidTest.php b/core/tests/Drupal/KernelTests/Components/ComponentRenderInvalidTest.php index 704c5ae1f6519a0212ae7d6fee2bc03d68859487..34ef43ec341a9c05378573def3cf619308989ab4 100644 --- a/core/tests/Drupal/KernelTests/Components/ComponentRenderInvalidTest.php +++ b/core/tests/Drupal/KernelTests/Components/ComponentRenderInvalidTest.php @@ -5,7 +5,6 @@ namespace Drupal\KernelTests\Components; use Drupal\Core\Render\Component\Exception\InvalidComponentException; -use Drupal\Tests\Core\Theme\Component\ComponentKernelTestBase; /** * Tests invalid render options for components. diff --git a/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php b/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php index 90d0fe6b8f91850591cc50964c5cd5dfa96b0f1f..959ab624cb68bd0c3e60e36073e9d551cbbab794 100644 --- a/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php +++ b/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php @@ -9,7 +9,6 @@ use Drupal\Core\Template\Attribute; use Drupal\Core\Theme\ComponentPluginManager; use Drupal\Core\Render\Component\Exception\InvalidComponentDataException; -use Drupal\Tests\Core\Theme\Component\ComponentKernelTestBase; /** * Tests the correct rendering of components. diff --git a/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php b/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php similarity index 94% rename from core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php rename to core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php index 0be3b942c637b7b753b3671492561e05d270fa6b..cf6a47e43ed43d93c2d816e8837e3125768ce01e 100644 --- a/core/tests/Drupal/Tests/Scripts/TestSiteApplicationTest.php +++ b/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Drupal\Tests\Scripts; +namespace Drupal\KernelTests\Scripts; use Drupal\Component\FileSystem\FileSystem; use Drupal\Core\Database\Database; use Drupal\Core\Test\TestDatabase; -use Drupal\Tests\UnitTestCase; +use Drupal\KernelTests\KernelTestBase; use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; use Symfony\Component\Process\PhpExecutableFinder; @@ -18,19 +18,18 @@ /** * Tests core/scripts/test-site.php. * - * @group Setup - * - * This test uses the Drupal\Core\Database\Database class which has a static. - * Therefore run in a separate process to avoid side effects. - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled + * This test uses the Drupal\Core\Database\Database class which has a static, + * and the CI database services. Therefore it is defined as KernelTest so that + * it can also run in a separate process to avoid side effects. * * @see \Drupal\TestSite\TestSiteApplication * @see \Drupal\TestSite\Commands\TestSiteInstallCommand * @see \Drupal\TestSite\Commands\TestSiteTearDownCommand + * + * @group Setup + * @preserveGlobalState disabled */ -class TestSiteApplicationTest extends UnitTestCase { +class TestSiteApplicationTest extends KernelTestBase { /** * The PHP executable path. @@ -81,7 +80,7 @@ public function testInstallWithNonSetupClass(): void { $process = Process::fromShellCommandline($command_line, $this->root, ['COLUMNS' => PHP_INT_MAX]); $process->run(); - $this->assertStringContainsString('The class Drupal\Tests\Scripts\TestSiteApplicationTest contained in', $process->getErrorOutput()); + $this->assertStringContainsString('The class Drupal\KernelTests\Scripts\TestSiteApplicationTest contained in', $process->getErrorOutput()); $this->assertStringContainsString('needs to implement \Drupal\TestSite\TestSetupInterface', $process->getErrorOutput()); } @@ -90,9 +89,6 @@ public function testInstallWithNonSetupClass(): void { */ public function testInstallScript(): void { $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest'; - if (!is_writable($simpletest_path)) { - $this->markTestSkipped("Requires the directory $simpletest_path to exist and be writable"); - } // Install a site using the JSON output. $command_line = $this->php . ' core/scripts/test-site.php install --json --setup-file core/tests/Drupal/TestSite/TestSiteInstallTestScript.php --db-url "' . getenv('SIMPLETEST_DB') . '"'; @@ -190,9 +186,6 @@ public function testInstallScript(): void { */ public function testInstallInDifferentLanguage(): void { $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest'; - if (!is_writable($simpletest_path)) { - $this->markTestSkipped("Requires the directory $simpletest_path to exist and be writable"); - } $command_line = $this->php . ' core/scripts/test-site.php install --json --langcode fr --setup-file core/tests/Drupal/TestSite/TestSiteMultilingualInstallTestScript.php --db-url "' . getenv('SIMPLETEST_DB') . '"'; $process = Process::fromShellCommandline($command_line, $this->root); @@ -240,9 +233,6 @@ public function testTearDownDbPrefixValidation(): void { public function testUserLogin(): void { $this->markTestIncomplete('Fix this test in https://www.drupal.org/project/drupal/issues/2962157.'); $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest'; - if (!is_writable($simpletest_path)) { - $this->markTestSkipped("Requires the directory $simpletest_path to exist and be writable"); - } // Install a site using the JSON output. $command_line = $this->php . ' core/scripts/test-site.php install --json --setup-file core/tests/Drupal/TestSite/TestSiteInstallTestScript.php --db-url "' . getenv('SIMPLETEST_DB') . '"'; diff --git a/core/tests/Drupal/TestSite/TestSiteClaroInstallTestScript.php b/core/tests/Drupal/TestSite/TestSiteClaroInstallTestScript.php index 4ab1b31f09621e5fb17d0524076a3959e5a8f6a9..88a49066957e66c9627a4842a8ec5825c03bf4ee 100644 --- a/core/tests/Drupal/TestSite/TestSiteClaroInstallTestScript.php +++ b/core/tests/Drupal/TestSite/TestSiteClaroInstallTestScript.php @@ -12,7 +12,7 @@ /** * Setup file used by TestSiteInstallTestScript. * - * @see \Drupal\Tests\Scripts\TestSiteApplicationTest + * @see \Drupal\KernelTests\Scripts\TestSiteApplicationTest */ class TestSiteClaroInstallTestScript implements TestSetupInterface { diff --git a/core/tests/Drupal/TestSite/TestSiteInstallTestScript.php b/core/tests/Drupal/TestSite/TestSiteInstallTestScript.php index 7fc5494e33e2820dd6e1a5732b633915c863365b..7ac073c6485e83112f4e217526b796e15219d665 100644 --- a/core/tests/Drupal/TestSite/TestSiteInstallTestScript.php +++ b/core/tests/Drupal/TestSite/TestSiteInstallTestScript.php @@ -7,7 +7,7 @@ /** * Setup file used by TestSiteApplicationTest. * - * @see \Drupal\Tests\Scripts\TestSiteApplicationTest + * @see \Drupal\KernelTests\Scripts\TestSiteApplicationTest */ class TestSiteInstallTestScript implements TestSetupInterface { diff --git a/core/tests/Drupal/TestSite/TestSiteMultilingualInstallTestScript.php b/core/tests/Drupal/TestSite/TestSiteMultilingualInstallTestScript.php index 2aa5d62cdb2f46874c4e09cbf126ebed00182896..31ed753e7339714c2571f53220a8564dc5e1f7d7 100644 --- a/core/tests/Drupal/TestSite/TestSiteMultilingualInstallTestScript.php +++ b/core/tests/Drupal/TestSite/TestSiteMultilingualInstallTestScript.php @@ -9,7 +9,7 @@ /** * Setup file used by TestSiteApplicationTest. * - * @see \Drupal\Tests\Scripts\TestSiteApplicationTest + * @see \Drupal\KernelTests\Scripts\TestSiteApplicationTest */ class TestSiteMultilingualInstallTestScript implements TestSetupInterface, TestPreinstallInterface { diff --git a/core/tests/Drupal/TestSite/TestSiteOliveroInstallTestScript.php b/core/tests/Drupal/TestSite/TestSiteOliveroInstallTestScript.php index 87f73336cf0cb0375d238b7294feb9c247168af1..9b6c36d1bad5d34b904c7a98b1e6c822dea02867 100644 --- a/core/tests/Drupal/TestSite/TestSiteOliveroInstallTestScript.php +++ b/core/tests/Drupal/TestSite/TestSiteOliveroInstallTestScript.php @@ -12,7 +12,7 @@ /** * Setup file used by TestSiteInstallTestScript. * - * @see \Drupal\Tests\Scripts\TestSiteApplicationTest + * @see \Drupal\KernelTests\Scripts\TestSiteApplicationTest */ class TestSiteOliveroInstallTestScript implements TestSetupInterface { diff --git a/core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php b/core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php index e872be584946ea9f583c3d105cda4905552a9817..92119258ec28a4201faa70259614e5376d18ffde 100644 --- a/core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php +++ b/core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php @@ -456,7 +456,7 @@ public static function providerTestGetPhpunitTestSuite() { $data['module-functional javascript test'] = ['\Drupal\Tests\toolbar\FunctionalJavascript\ToolbarIntegrationTest', 'FunctionalJavascript']; $data['core-unittest'] = ['\Drupal\Tests\ComposerIntegrationTest', 'Unit']; $data['core-unittest2'] = ['Drupal\Tests\Core\DrupalTest', 'Unit']; - $data['core-unittest3'] = ['Drupal\Tests\Scripts\TestSiteApplicationTest', 'Unit']; + $data['core-script-test'] = ['Drupal\KernelTests\Scripts\TestSiteApplicationTest', 'Kernel']; $data['core-kernel test'] = ['\Drupal\KernelTests\KernelTestBaseTest', 'Kernel']; $data['core-functional test'] = ['\Drupal\FunctionalTests\ExampleTest', 'Functional']; $data['core-functional javascript test'] = ['\Drupal\FunctionalJavascriptTests\ExampleTest', 'FunctionalJavascript'];