function RoleTest::providerSource

Same name in this branch
  1. 10 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/RoleTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d7\RoleTest::providerSource()
Same name in other branches
  1. 9 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d6\RoleTest::providerSource()
  2. 9 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/RoleTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d7\RoleTest::providerSource()
  3. 8.9.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d6\RoleTest::providerSource()
  4. 8.9.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/RoleTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d7\RoleTest::providerSource()
  5. 11.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d6\RoleTest::providerSource()
  6. 11.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/RoleTest.php \Drupal\Tests\user\Kernel\Plugin\migrate\source\d7\RoleTest::providerSource()

File

core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php, line 25

Class

RoleTest
Tests the d6_user_role source plugin.

Namespace

Drupal\Tests\user\Kernel\Plugin\migrate\source\d6

Code

public static function providerSource() {
    $tests = [
        [
            'source_data' => [],
            'expected_data' => [],
        ],
    ];
    $roles = [
        [
            'rid' => 1,
            'name' => 'anonymous user',
            'permissions' => [
                'access content',
            ],
        ],
        [
            'rid' => 2,
            'name' => 'authenticated user',
            'permissions' => [
                'access comments',
                'access content',
                'post comments',
                'post comments without approval',
            ],
        ],
        [
            'rid' => 3,
            'name' => 'administrator',
            'permissions' => [
                'access comments',
                'administer comments',
                'post comments',
                'post comments without approval',
                'access content',
                'administer content types',
                'administer nodes',
            ],
        ],
    ];
    // The source data.
    foreach ($roles as $role) {
        $tests[0]['source_data']['permission'][] = [
            'rid' => $role['rid'],
            'perm' => implode(', ', $role['permissions']),
        ];
        unset($role['permissions']);
        $tests[0]['source_data']['role'][] = $role;
    }
    $tests[0]['source_data']['filter_formats'] = [
        [
            'format' => 1,
            'roles' => '',
        ],
    ];
    // The expected results.
    $tests[0]['expected_data'] = $roles;
    return $tests;
}

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