diff --git a/core/lib/Drupal/Core/Test/TestDiscovery.php b/core/lib/Drupal/Core/Test/TestDiscovery.php index a90587c52dd398a72bbc2ffc556b918c2fbbf017..6a4e8facfd5f6ad00ea6d97e99d2a14af294aa69 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 0000000000000000000000000000000000000000..4fbbe80c70fbcbe155be89002aa8c7cc411aba3b --- /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 36168ff4623f0e3fa5dbfe8d1248ce877666ca6a..851579d320c2ddcc540fbd60aa27f8757370e824 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 0000000000000000000000000000000000000000..a88b9e258d44fbfb74317d35dffc9ad7070434f3 --- /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 0000000000000000000000000000000000000000..34fa7beaf59f79e6cf1acea1ee0f5e20b6ba2c78 --- /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 0000000000000000000000000000000000000000..f054de858227a44b41f802adae88b7c671f5a522 --- /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 0000000000000000000000000000000000000000..80e7a2229d1c786dac676ac7a52d5af78c2714ff --- /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 0000000000000000000000000000000000000000..eadb51ea245ec6b5c7d735ad499072cff015abb6 --- /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 0000000000000000000000000000000000000000..2d1038a6a63cc2985df31b0209949226e5e676a0 --- /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 0000000000000000000000000000000000000000..c6d68820031ff983f86fca5c66c5365a3138f4ce --- /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 0000000000000000000000000000000000000000..64e0e1d5334c0596b0c545814fedcf6a017f1da6 --- /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 0000000000000000000000000000000000000000..b3c5bc32ff65a45ce7d5a971298a5941cbfcb4dc --- /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 0000000000000000000000000000000000000000..e2c20aa6b1caa40067fd910526cc8e07063f1ced --- /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 0000000000000000000000000000000000000000..f78077cfffb667cbcda7b9172d09834d87730b64 --- /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 0000000000000000000000000000000000000000..b48e1b0c79fafc3aa74ab8288f7b7e3f8c74fc59 --- /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 0000000000000000000000000000000000000000..6aa4007d39b48bffff71e27fe517a58c2e9821ac --- /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 0000000000000000000000000000000000000000..4dcb675e6e88cdffad3c3f9460450b995169cf2a --- /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 0000000000000000000000000000000000000000..416426ddeefdc33e79290b8cb106171e01e529a0 --- /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 0000000000000000000000000000000000000000..d7c336a129a580fe26eff4acfd992f4bf300d4f8 --- /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 0000000000000000000000000000000000000000..9e02c77db6ff60d26773a31c073082969cd62fb6 --- /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 0000000000000000000000000000000000000000..e9fec12aff762ec4fe6019d78fa6e985aad2c65b --- /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 0000000000000000000000000000000000000000..7ab5063335a177a327463e19341bbf873fbed5b9 --- /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 0000000000000000000000000000000000000000..b3da56dd298653fe20f0bc0745e0d5a539948774 --- /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 0000000000000000000000000000000000000000..04946b7e71cdef3ce52f170fa0e80d33540201b9 --- /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 0000000000000000000000000000000000000000..154c58eae0bbff78248555e6cc02327bb2c082f5 --- /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 0000000000000000000000000000000000000000..13a2391d16440ff9bef214b3ff3d4535ae899acf --- /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 0000000000000000000000000000000000000000..5c5f55fe781af0c7d86b55bd1c8662ab19822081 --- /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 0000000000000000000000000000000000000000..e496531c5c6dcf72d22028f15fc0bec233e01ef7 --- /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 0000000000000000000000000000000000000000..73d802261f97d03c2247ffffdc074481ac31eb49 --- /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 0000000000000000000000000000000000000000..754bb283ddde8edc22e9a5c45e718c35a23a18d6 --- /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 0000000000000000000000000000000000000000..384cd870f1b19182b029ad5641a4445b538c49fc --- /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 0d4c7f2669fc044466db64d46ed8f265975ae32f..c60fc97a1d1b11ccdb8eb929bf7b51fb00f8ee80 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'); } }