function EnabledExtensionsValidatorTest::createExtension

Returns a mocked extension object for a package.

Parameters

string $project_root: The project root directory.

string $package_type: The package type (e.g., `drupal-module` or `drupal-theme`).

string $extension_name: The name of the extension.

Return value

\Drupal\Core\Extension\Extension An extension object.

1 call to EnabledExtensionsValidatorTest::createExtension()
EnabledExtensionsValidatorTest::testExtensionRemoved in core/modules/package_manager/tests/src/Kernel/EnabledExtensionsValidatorTest.php
Tests that error is raised if Drupal modules, profiles or themes are removed.

File

core/modules/package_manager/tests/src/Kernel/EnabledExtensionsValidatorTest.php, line 149

Class

EnabledExtensionsValidatorTest
@covers \Drupal\package_manager\Validator\EnabledExtensionsValidator @group package_manager @internal

Namespace

Drupal\Tests\package_manager\Kernel

Code

private static function createExtension(string $project_root, string $package_type, string $extension_name) : Extension {
    $type = match ($package_type) {    'drupal-theme' => 'theme',
        'drupal-profile' => 'profile',
        default => 'module',
    
    };
    $subdirectory = match ($type) {    'theme' => 'themes',
        'profile' => 'profiles',
        'module' => 'modules',
    
    };
    return new Extension($project_root, $type, "{$subdirectory}/contrib/{$extension_name}/{$extension_name}.info.yml");
}

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