View source
<?php
namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
class RoleTest extends MigrateSqlSourceTestBase {
protected static $modules = [
'user',
'migrate_drupal',
];
public 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',
],
],
];
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' => '',
],
];
$tests[0]['expected_data'] = $roles;
return $tests;
}
}