Loading core/lib/Drupal/Core/Test/TestDiscovery.php +9 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading core/modules/system/tests/src/Functional/Recipe/GenericRecipeTestBase.php 0 → 100644 +55 −0 Original line number Diff line number Diff line <?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(); } } core/phpunit.xml.dist +3 −0 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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> Loading @@ -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> Loading core/recipes/administrator_role/tests/src/Functional/GenericTest.php 0 → 100644 +12 −0 Original line number Diff line number Diff line <?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 {} core/recipes/article_comment/tests/src/Functional/GenericTest.php 0 → 100644 +12 −0 Original line number Diff line number Diff line <?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 {} Loading
core/lib/Drupal/Core/Test/TestDiscovery.php +9 −0 Original line number Diff line number Diff line Loading @@ -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); } Loading
core/modules/system/tests/src/Functional/Recipe/GenericRecipeTestBase.php 0 → 100644 +55 −0 Original line number Diff line number Diff line <?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(); } }
core/phpunit.xml.dist +3 −0 Original line number Diff line number Diff line Loading @@ -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> Loading @@ -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> Loading @@ -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> Loading
core/recipes/administrator_role/tests/src/Functional/GenericTest.php 0 → 100644 +12 −0 Original line number Diff line number Diff line <?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 {}
core/recipes/article_comment/tests/src/Functional/GenericTest.php 0 → 100644 +12 −0 Original line number Diff line number Diff line <?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 {}