CoreRecipesTest.php

Same filename in this branch
  1. 11.x core/tests/Drupal/FunctionalTests/Core/Recipe/CoreRecipesTest.php
Same filename in other branches
  1. 10 core/tests/Drupal/FunctionalTests/Core/Recipe/CoreRecipesTest.php

Namespace

Drupal\Tests\Core\Recipe

File

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

View source
<?php

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

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

/**
 * Tests that all core recipes have a generic test.
 *
 * @group Recipe
 */
class CoreRecipesTest extends UnitTestCase {
    
    /**
     * Data provider for ::testRecipeHasGenericTest().
     *
     * @return iterable<array<string>>
     *   An iterable containing paths to recipe files.
     */
    public static function providerRecipeHasGenericTest() : iterable {
        $finder = Finder::create()->in([
            dirname(__DIR__, 5) . '/recipes',
        ])
            ->directories()
            ->depth(0)
            ->notName([
            'example',
        ]);
        static::assertGreaterThan(0, count($finder), 'No core recipes were found.');
        $scenarios = [];
        
        /** @var \Symfony\Component\Finder\SplFileInfo $recipe */
        foreach ($finder as $recipe) {
            $name = $recipe->getBasename();
            $scenarios[$name] = [
                $recipe->getPathname(),
            ];
        }
        return $scenarios;
    }
    
    /**
     * Test that a recipe has a generic test.
     *
     * @param string $path
     *   The path to the recipe file.
     *
     * @dataProvider providerRecipeHasGenericTest
     */
    public function testRecipeHasGenericTest(string $path) : void {
        $this->assertFileExists($path . '/tests/src/Functional/GenericTest.php');
    }

}

Classes

Title Deprecated Summary
CoreRecipesTest Tests that all core recipes have a generic test.

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