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);
    }

}

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.