CoreRecipesTest.php

Same filename and directory in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Recipe/CoreRecipesTest.php
  2. main core/tests/Drupal/Tests/Core/Recipe/CoreRecipesTest.php

Namespace

Drupal\FunctionalTests\Core\Recipe

File

core/tests/Drupal/FunctionalTests/Core/Recipe/CoreRecipesTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\FunctionalTests\Core\Recipe;

use Drupal\Tests\BrowserTestBase;
use Symfony\Component\Finder\Finder;

/**
 * Tests applying all core-provided recipes on top of the Empty profile.
 *
 * @group Recipe
 * @group #slow
 */
class CoreRecipesTest extends BrowserTestBase {
  use RecipeTestTrait;
  
  /**
   * {@inheritdoc}
   */
  protected $profile = 'minimal';
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';
  
  /**
   * The data provider for apply recipe test.
   *
   * @return iterable<array<string>>
   *   An iterable containing paths to recipe files.
   */
  public static function providerApplyRecipe() : iterable {
    $finder = Finder::create()->in([
      static::getDrupalRoot() . '/core/recipes',
    ])
      ->directories()
      ->depth(0)
      ->notName([
      'example',
    ]);
    $scenarios = [];
    /** @var \Symfony\Component\Finder\SplFileInfo $recipe */
    foreach ($finder as $recipe) {
      $name = $recipe->getBasename();
      $scenarios[$name] = [
        $recipe->getPathname(),
      ];
    }
    return $scenarios;
  }
  
  /**
   * Test the recipe apply.
   *
   * @param string $path
   *   The path to the recipe file.
   *
   * @dataProvider providerApplyRecipe
   */
  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);
  }

}

Classes

Title Deprecated Summary
CoreRecipesTest Tests applying all core-provided recipes on top of the Empty profile.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.