function DuplicateInfoFileValidatorTest::providerDuplicateInfoFilesInStage

Data provider for testDuplicateInfoFilesInStage.

Return value

mixed[][] The test cases.

File

core/modules/package_manager/tests/src/Kernel/DuplicateInfoFileValidatorTest.php, line 25

Class

DuplicateInfoFileValidatorTest
@covers \Drupal\package_manager\Validator\DuplicateInfoFileValidator @group package_manager @internal

Namespace

Drupal\Tests\package_manager\Kernel

Code

public static function providerDuplicateInfoFilesInStage() : array {
    return [
        'Duplicate info.yml files in stage' => [
            [
                '/module.info.yml',
            ],
            [
                '/module.info.yml',
                '/modules/module.info.yml',
            ],
            [
                ValidationResult::createError([
                    t('The stage directory has 2 instances of module.info.yml as compared to 1 in the active directory. This likely indicates that a duplicate extension was installed.'),
                ]),
            ],
        ],
        // Duplicate files in stage but having different extension which we don't
        // care about.
'Duplicate info files in stage' => [
            [
                '/my_file.info',
            ],
            [
                '/my_file.info',
                '/modules/my_file.info',
            ],
            [],
        ],
        'Duplicate info.yml files in stage with one file in tests/fixtures folder' => [
            [
                '/tests/fixtures/module.info.yml',
            ],
            [
                '/tests/fixtures/module.info.yml',
                '/modules/module.info.yml',
            ],
            [],
        ],
        'Duplicate info.yml files in stage with one file in tests/modules folder' => [
            [
                '/tests/modules/module.info.yml',
            ],
            [
                '/tests/modules/module.info.yml',
                '/modules/module.info.yml',
            ],
            [],
        ],
        'Duplicate info.yml files in stage with one file in tests/themes folder' => [
            [
                '/tests/themes/theme.info.yml',
            ],
            [
                '/tests/themes/theme.info.yml',
                '/themes/theme.info.yml',
            ],
            [],
        ],
        'Duplicate info.yml files in stage with one file in tests/profiles folder' => [
            [
                '/tests/profiles/profile.info.yml',
            ],
            [
                '/tests/profiles/profile.info.yml',
                '/profiles/profile.info.yml',
            ],
            [],
        ],
        'Duplicate info.yml files in stage not present in active' => [
            [],
            [
                '/module.info.yml',
                '/modules/module.info.yml',
            ],
            [
                ValidationResult::createError([
                    t('The stage directory has 2 instances of module.info.yml. This likely indicates that a duplicate extension was installed.'),
                ]),
            ],
        ],
        'Duplicate info.yml files in active' => [
            [
                '/module.info.yml',
                '/modules/module.info.yml',
            ],
            [
                '/module.info.yml',
            ],
            [],
        ],
        'Same number of info.yml files in active and stage' => [
            [
                '/module.info.yml',
                '/modules/module.info.yml',
            ],
            [
                '/module.info.yml',
                '/modules/module.info.yml',
            ],
            [],
        ],
        'Multiple duplicate info.yml files in stage' => [
            [
                '/modules/module1/module1.info.yml',
                '/modules/module2/module2.info.yml',
            ],
            [
                '/modules/module1/module1.info.yml',
                '/modules/module2/module2.info.yml',
                '/modules/foo/module1.info.yml',
                '/modules/bar/module2.info.yml',
                '/modules/baz/module2.info.yml',
            ],
            [
                ValidationResult::createError([
                    t('The stage directory has 3 instances of module2.info.yml as compared to 1 in the active directory. This likely indicates that a duplicate extension was installed.'),
                ]),
                ValidationResult::createError([
                    t('The stage directory has 2 instances of module1.info.yml as compared to 1 in the active directory. This likely indicates that a duplicate extension was installed.'),
                ]),
            ],
        ],
        'Multiple duplicate info.yml files in stage not present in active' => [
            [],
            [
                '/modules/module1/module1.info.yml',
                '/modules/module2/module2.info.yml',
                '/modules/foo/module1.info.yml',
                '/modules/bar/module2.info.yml',
                '/modules/baz/module2.info.yml',
            ],
            [
                ValidationResult::createError([
                    t('The stage directory has 3 instances of module2.info.yml. This likely indicates that a duplicate extension was installed.'),
                ]),
                ValidationResult::createError([
                    t('The stage directory has 2 instances of module1.info.yml. This likely indicates that a duplicate extension was installed.'),
                ]),
            ],
        ],
        'Multiple duplicate info.yml files in stage with one info.yml file not present in active' => [
            [
                '/modules/module1/module1.info.yml',
            ],
            [
                '/modules/module1/module1.info.yml',
                '/modules/module2/module2.info.yml',
                '/modules/foo/module1.info.yml',
                '/modules/bar/module2.info.yml',
                '/modules/baz/module2.info.yml',
            ],
            [
                ValidationResult::createError([
                    t('The stage directory has 3 instances of module2.info.yml. This likely indicates that a duplicate extension was installed.'),
                ]),
                ValidationResult::createError([
                    t('The stage directory has 2 instances of module1.info.yml as compared to 1 in the active directory. This likely indicates that a duplicate extension was installed.'),
                ]),
            ],
        ],
    ];
}

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