RoleTest.php

Same filename in this branch
  1. 8.9.x core/modules/jsonapi/tests/src/Functional/RoleTest.php
  2. 8.9.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php
Same filename and directory in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/RoleTest.php
  2. 9 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php
  3. 9 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/RoleTest.php
  4. 10 core/modules/jsonapi/tests/src/Functional/RoleTest.php
  5. 10 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php
  6. 10 core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/RoleTest.php
  7. 11.x core/modules/jsonapi/tests/src/Functional/RoleTest.php
  8. 11.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/d6/RoleTest.php
  9. 11.x core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/RoleTest.php

Namespace

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

File

core/modules/user/tests/src/Kernel/Plugin/migrate/source/d7/RoleTest.php

View source
<?php

namespace Drupal\Tests\user\Kernel\Plugin\migrate\source\d7;

use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;

/**
 * Tests the d7_user_role source plugin.
 *
 * @covers \Drupal\user\Plugin\migrate\source\d7\Role
 * @group user
 */
class RoleTest extends MigrateSqlSourceTestBase {
    
    /**
     * {@inheritdoc}
     */
    public static $modules = [
        'migrate_drupal',
        'user',
    ];
    
    /**
     * {@inheritdoc}
     */
    public function providerSource() {
        $expected = [
            [
                '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',
                ],
            ],
        ];
        $data = [
            [
                [],
                $expected,
            ],
        ];
        foreach ($expected as $row) {
            foreach ($row['permissions'] as $permission) {
                $data[0][0]['role_permission'][] = [
                    'permission' => $permission,
                    'rid' => $row['rid'],
                ];
            }
            unset($row['permissions']);
            $data[0][0]['role'][] = $row;
        }
        return $data;
    }

}

Classes

Title Deprecated Summary
RoleTest Tests the d7_user_role source plugin.

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