From 701d8f1609cb1372455ac164cd602b93a7a3ea51 Mon Sep 17 00:00:00 2001 From: catch <6915-catch@users.noreply.drupalcode.org> Date: Mon, 22 Jul 2024 18:12:20 +0900 Subject: [PATCH] Issue #3462383 by phenaproxima, catch, alexpott, longwave: CoreRecipesTest is slow --- core/lib/Drupal/Core/Test/TestDiscovery.php | 9 +++ .../Recipe/GenericRecipeTestBase.php | 55 +++++++++++++++++++ core/phpunit.xml.dist | 3 + .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../tests/src/Functional/GenericTest.php | 12 ++++ .../Core/Recipe/CoreRecipesTest.php | 39 ++++--------- 32 files changed, 415 insertions(+), 27 deletions(-) create mode 100644 core/modules/system/tests/src/Functional/Recipe/GenericRecipeTestBase.php create mode 100644 core/recipes/administrator_role/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/article_comment/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/article_content_type/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/article_tags/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/audio_media_type/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/basic_block_type/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/basic_html_format_editor/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/basic_shortcuts/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/comment_base/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/content_editor_role/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/content_search/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/core_recommended_admin_theme/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/core_recommended_front_end_theme/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/core_recommended_maintenance/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/core_recommended_performance/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/document_media_type/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/editorial_workflow/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/feedback_contact_form/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/full_html_format_editor/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/image_media_type/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/local_video_media_type/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/page_content_type/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/remote_video_media_type/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/restricted_html_format/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/standard/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/standard_responsive_images/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/tags_taxonomy/tests/src/Functional/GenericTest.php create mode 100644 core/recipes/user_picture/tests/src/Functional/GenericTest.php rename core/tests/Drupal/{FunctionalTests => Tests}/Core/Recipe/CoreRecipesTest.php (51%) diff --git a/core/lib/Drupal/Core/Test/TestDiscovery.php b/core/lib/Drupal/Core/Test/TestDiscovery.php index a90587c52dd3..6a4e8facfd5f 100644 --- a/core/lib/Drupal/Core/Test/TestDiscovery.php +++ b/core/lib/Drupal/Core/Test/TestDiscovery.php @@ -106,6 +106,15 @@ public function registerTestNamespaces() { $this->testNamespaces["Drupal\\Tests\\$name\\"][] = "$base_path/tests/src"; } + // Expose tests provided by core recipes. + $base_path = $this->root . '/core/recipes'; + if (@opendir($base_path)) { + while (($recipe = readdir()) !== FALSE) { + $this->testNamespaces["Drupal\\Tests\\Recipe\\Core\\$recipe\\"][] = "$base_path/$recipe/tests/src"; + } + closedir(); + } + foreach ($this->testNamespaces as $prefix => $paths) { $this->classLoader->addPsr4($prefix, $paths); } diff --git a/core/modules/system/tests/src/Functional/Recipe/GenericRecipeTestBase.php b/core/modules/system/tests/src/Functional/Recipe/GenericRecipeTestBase.php new file mode 100644 index 000000000000..4fbbe80c70fb --- /dev/null +++ b/core/modules/system/tests/src/Functional/Recipe/GenericRecipeTestBase.php @@ -0,0 +1,55 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\system\Functional\Recipe; + +use Drupal\FunctionalTests\Core\Recipe\RecipeTestTrait; +use Drupal\Tests\BrowserTestBase; + +/** + * Runs a series of generic tests for one recipe. + */ +abstract class GenericRecipeTestBase extends BrowserTestBase { + + use RecipeTestTrait; + + /** + * {@inheritdoc} + */ + protected $profile = 'minimal'; + + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + + /** + * Returns the path of the recipe under test. + * + * @return string + * The absolute path of the recipe that contains this test. + */ + protected function getRecipePath(): string { + // Assume this test in located in RECIPE_DIR/tests/src/Functional. + return dirname((new \ReflectionObject($this))->getFileName(), 4); + } + + /** + * Applies the recipe under test. + */ + protected function doApply(): void { + $this->applyRecipe($this->getRecipePath()); + } + + /** + * Tests that this recipe can be applied multiple times. + */ + public function testRecipeCanBeApplied(): void { + $this->setUpCurrentUser(admin: TRUE); + $this->doApply(); + // Apply the recipe again to prove that it is idempotent. + $this->doApply(); + } + +} diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist index 36168ff4623f..851579d320c2 100644 --- a/core/phpunit.xml.dist +++ b/core/phpunit.xml.dist @@ -88,6 +88,7 @@ <testsuite name="kernel"> <directory>tests/Drupal/KernelTests</directory> <directory>modules/**/tests/src/Kernel</directory> + <directory>recipes/*/tests/src/Kernel</directory> <directory>profiles/**/tests/src/Kernel</directory> <directory>themes/**/tests/src/Kernel</directory> <directory>../modules/**/tests/src/Kernel</directory> @@ -98,6 +99,7 @@ <directory>tests/Drupal/FunctionalTests</directory> <directory>modules/**/tests/src/Functional</directory> <directory>profiles/**/tests/src/Functional</directory> + <directory>recipes/*/tests/src/Functional</directory> <directory>themes/**/tests/src/Functional</directory> <directory>../modules/**/tests/src/Functional</directory> <directory>../profiles/**/tests/src/Functional</directory> @@ -106,6 +108,7 @@ <testsuite name="functional-javascript"> <directory>tests/Drupal/FunctionalJavascriptTests</directory> <directory>modules/**/tests/src/FunctionalJavascript</directory> + <directory>recipes/*/tests/src/FunctionalJavascript</directory> <directory>profiles/**/tests/src/FunctionalJavascript</directory> <directory>themes/**/tests/src/FunctionalJavascript</directory> <directory>../modules/**/tests/src/FunctionalJavascript</directory> diff --git a/core/recipes/administrator_role/tests/src/Functional/GenericTest.php b/core/recipes/administrator_role/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..a88b9e258d44 --- /dev/null +++ b/core/recipes/administrator_role/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\administrator_role\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_administrator_role_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/article_comment/tests/src/Functional/GenericTest.php b/core/recipes/article_comment/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..34fa7beaf59f --- /dev/null +++ b/core/recipes/article_comment/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\article_comment\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_article_comment_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/article_content_type/tests/src/Functional/GenericTest.php b/core/recipes/article_content_type/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..f054de858227 --- /dev/null +++ b/core/recipes/article_content_type/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\article_content_type\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_article_content_type_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/article_tags/tests/src/Functional/GenericTest.php b/core/recipes/article_tags/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..80e7a2229d1c --- /dev/null +++ b/core/recipes/article_tags/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\article_tags\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_article_tags_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/audio_media_type/tests/src/Functional/GenericTest.php b/core/recipes/audio_media_type/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..eadb51ea245e --- /dev/null +++ b/core/recipes/audio_media_type/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\audio_media_type\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_audio_media_type_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/basic_block_type/tests/src/Functional/GenericTest.php b/core/recipes/basic_block_type/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..2d1038a6a63c --- /dev/null +++ b/core/recipes/basic_block_type/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\basic_block_type\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_basic_block_type_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/basic_html_format_editor/tests/src/Functional/GenericTest.php b/core/recipes/basic_html_format_editor/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..c6d68820031f --- /dev/null +++ b/core/recipes/basic_html_format_editor/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\basic_html_format_editor\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_basic_html_format_editor_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/basic_shortcuts/tests/src/Functional/GenericTest.php b/core/recipes/basic_shortcuts/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..64e0e1d5334c --- /dev/null +++ b/core/recipes/basic_shortcuts/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\basic_shortcuts\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_basic_shortcuts_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/comment_base/tests/src/Functional/GenericTest.php b/core/recipes/comment_base/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..b3c5bc32ff65 --- /dev/null +++ b/core/recipes/comment_base/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\comment_base\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_comment_base_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/content_editor_role/tests/src/Functional/GenericTest.php b/core/recipes/content_editor_role/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..e2c20aa6b1ca --- /dev/null +++ b/core/recipes/content_editor_role/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\content_editor_role\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_content_editor_role_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/content_search/tests/src/Functional/GenericTest.php b/core/recipes/content_search/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..f78077cfffb6 --- /dev/null +++ b/core/recipes/content_search/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\content_search\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_content_search_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/core_recommended_admin_theme/tests/src/Functional/GenericTest.php b/core/recipes/core_recommended_admin_theme/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..b48e1b0c79fa --- /dev/null +++ b/core/recipes/core_recommended_admin_theme/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\core_recommended_admin_theme\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_recommended_admin_theme_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/core_recommended_front_end_theme/tests/src/Functional/GenericTest.php b/core/recipes/core_recommended_front_end_theme/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..6aa4007d39b4 --- /dev/null +++ b/core/recipes/core_recommended_front_end_theme/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\core_recommended_front_end_theme\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_recommended_front_end_theme_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/core_recommended_maintenance/tests/src/Functional/GenericTest.php b/core/recipes/core_recommended_maintenance/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..4dcb675e6e88 --- /dev/null +++ b/core/recipes/core_recommended_maintenance/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\core_recommended_maintenance\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_recommended_maintenance_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/core_recommended_performance/tests/src/Functional/GenericTest.php b/core/recipes/core_recommended_performance/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..416426ddeefd --- /dev/null +++ b/core/recipes/core_recommended_performance/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\core_recommended_performance\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_recommended_performance_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/document_media_type/tests/src/Functional/GenericTest.php b/core/recipes/document_media_type/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..d7c336a129a5 --- /dev/null +++ b/core/recipes/document_media_type/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\document_media_type\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_document_media_type_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/editorial_workflow/tests/src/Functional/GenericTest.php b/core/recipes/editorial_workflow/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..9e02c77db6ff --- /dev/null +++ b/core/recipes/editorial_workflow/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\editorial_workflow\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_editorial_workflow_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/feedback_contact_form/tests/src/Functional/GenericTest.php b/core/recipes/feedback_contact_form/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..e9fec12aff76 --- /dev/null +++ b/core/recipes/feedback_contact_form/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\feedback_contact_form\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_feedback_contact_form_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/full_html_format_editor/tests/src/Functional/GenericTest.php b/core/recipes/full_html_format_editor/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..7ab5063335a1 --- /dev/null +++ b/core/recipes/full_html_format_editor/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\full_html_format_editor\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_full_html_format_editor_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/image_media_type/tests/src/Functional/GenericTest.php b/core/recipes/image_media_type/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..b3da56dd2986 --- /dev/null +++ b/core/recipes/image_media_type/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\image_media_type\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_image_media_type_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/local_video_media_type/tests/src/Functional/GenericTest.php b/core/recipes/local_video_media_type/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..04946b7e71cd --- /dev/null +++ b/core/recipes/local_video_media_type/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\local_video_media_type\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_local_video_media_type_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/page_content_type/tests/src/Functional/GenericTest.php b/core/recipes/page_content_type/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..154c58eae0bb --- /dev/null +++ b/core/recipes/page_content_type/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\page_content_type\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_page_content_type_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/remote_video_media_type/tests/src/Functional/GenericTest.php b/core/recipes/remote_video_media_type/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..13a2391d1644 --- /dev/null +++ b/core/recipes/remote_video_media_type/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\remote_video_media_type\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_remote_video_media_type_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/restricted_html_format/tests/src/Functional/GenericTest.php b/core/recipes/restricted_html_format/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..5c5f55fe781a --- /dev/null +++ b/core/recipes/restricted_html_format/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\restricted_html_format\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_restricted_html_format_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/standard/tests/src/Functional/GenericTest.php b/core/recipes/standard/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..e496531c5c6d --- /dev/null +++ b/core/recipes/standard/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\standard\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_standard_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/standard_responsive_images/tests/src/Functional/GenericTest.php b/core/recipes/standard_responsive_images/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..73d802261f97 --- /dev/null +++ b/core/recipes/standard_responsive_images/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\standard_responsive_images\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_standard_responsive_images_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/tags_taxonomy/tests/src/Functional/GenericTest.php b/core/recipes/tags_taxonomy/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..754bb283ddde --- /dev/null +++ b/core/recipes/tags_taxonomy/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\tags_taxonomy\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_tags_taxonomy_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/recipes/user_picture/tests/src/Functional/GenericTest.php b/core/recipes/user_picture/tests/src/Functional/GenericTest.php new file mode 100644 index 000000000000..384cd870f1b1 --- /dev/null +++ b/core/recipes/user_picture/tests/src/Functional/GenericTest.php @@ -0,0 +1,12 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Recipe\Core\user_picture\Functional; + +use Drupal\Tests\system\Functional\Recipe\GenericRecipeTestBase; + +/** + * @group core_user_picture_recipe + */ +class GenericTest extends GenericRecipeTestBase {} diff --git a/core/tests/Drupal/FunctionalTests/Core/Recipe/CoreRecipesTest.php b/core/tests/Drupal/Tests/Core/Recipe/CoreRecipesTest.php similarity index 51% rename from core/tests/Drupal/FunctionalTests/Core/Recipe/CoreRecipesTest.php rename to core/tests/Drupal/Tests/Core/Recipe/CoreRecipesTest.php index 0d4c7f2669fc..c60fc97a1d1b 100644 --- a/core/tests/Drupal/FunctionalTests/Core/Recipe/CoreRecipesTest.php +++ b/core/tests/Drupal/Tests/Core/Recipe/CoreRecipesTest.php @@ -2,41 +2,28 @@ declare(strict_types=1); -namespace Drupal\FunctionalTests\Core\Recipe; +namespace Drupal\Tests\Core\Recipe; -use Drupal\Tests\BrowserTestBase; +use Drupal\Tests\UnitTestCase; use Symfony\Component\Finder\Finder; /** - * Tests applying all core-provided recipes on top of the Empty profile. + * Tests that all core recipes have a generic test. * * @group Recipe - * @group #slow */ -class CoreRecipesTest extends BrowserTestBase { - - use RecipeTestTrait; - - /** - * {@inheritdoc} - */ - protected $profile = 'minimal'; - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; +class CoreRecipesTest extends UnitTestCase { /** - * The data provider for apply recipe test. + * Data provider for ::testRecipeHasGenericTest(). * * @return iterable<array<string>> * An iterable containing paths to recipe files. */ - public static function providerApplyRecipe(): iterable { + public static function providerRecipeHasGenericTest(): iterable { $finder = Finder::create() ->in([ - static::getDrupalRoot() . '/core/recipes', + dirname(__DIR__, 5) . '/recipes', ]) ->directories() // Recipes can't contain other recipes, so we don't need to search in @@ -44,6 +31,7 @@ public static function providerApplyRecipe(): iterable { ->depth(0) // The Example recipe is for documentation only, and cannot be applied. ->notName(['example']); + static::assertGreaterThan(0, count($finder), 'No core recipes were found.'); $scenarios = []; /** @var \Symfony\Component\Finder\SplFileInfo $recipe */ @@ -57,18 +45,15 @@ public static function providerApplyRecipe(): iterable { } /** - * Test the recipe apply. + * Test that a recipe has a generic test. * * @param string $path * The path to the recipe file. * - * @dataProvider providerApplyRecipe + * @dataProvider providerRecipeHasGenericTest */ - public function testApplyRecipe(string $path): void { - $this->setUpCurrentUser(admin: TRUE); - $this->applyRecipe($path); - // Apply the recipe again to prove that it is idempotent. - $this->applyRecipe($path); + public function testRecipeHasGenericTest(string $path): void { + $this->assertFileExists($path . '/tests/src/Functional/GenericTest.php'); } } -- GitLab