function MachineNameTest::providerTestMachineNames

Same name in other branches
  1. 10 core/modules/migrate/tests/src/Unit/process/MachineNameTest.php \Drupal\Tests\migrate\Unit\process\MachineNameTest::providerTestMachineNames()
  2. 11.x 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 71

Class

MachineNameTest
Tests the machine name process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public 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.