Commit e47f22df authored by catch's avatar catch
Browse files

Issue #3462383 by phenaproxima, catch, alexpott, longwave: CoreRecipesTest is slow

(cherry picked from commit 701d8f16)
parent c1976a98
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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);
    }
+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();
  }

}
+3 −0
Original line number Diff line number Diff line
@@ -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>
+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 {}
+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