function MachineNameTest::providerTestMachineNames

Same name and namespace in other branches
  1. 9 core/modules/migrate/tests/src/Unit/process/MachineNameTest.php \Drupal\Tests\migrate\Unit\process\MachineNameTest::providerTestMachineNames()
  2. 10 core/modules/migrate/tests/src/Unit/process/MachineNameTest.php \Drupal\Tests\migrate\Unit\process\MachineNameTest::providerTestMachineNames()

Provides test cases for MachineNameTest::testMachineNames().

Return value

array An array of test cases.

File

core/modules/migrate/tests/src/Unit/process/MachineNameTest.php, line 73

Class

MachineNameTest
Tests the machine name process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public static function providerTestMachineNames() : array {
    return [
        // Tests the following transformations:
        // - non-alphanumeric character (including spaces) -> underscore,
        // - Uppercase -> lowercase,
        // - Multiple consecutive underscore -> single underscore.
'default' => [
            'human_name' => 'foo2, the.bar;2*&the%baz!YEE____HaW áéő',
            'configuration' => [],
            'expected_result' => 'foo2_the_bar_2_the_baz_yee_haw_aeo',
        ],
        // Tests with a different pattern that allows periods.
'period_allowed' => [
            'human_name' => '2*&the%baz!YEE____HaW áéő.jpg',
            'configuration' => [
                'replace_pattern' => '/[^a-z0-9_.]+/',
            ],
            'expected_result' => '2_the_baz_yee_haw_aeo.jpg',
        ],
    ];
}

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