You are here

public function OgMembershipTest::saveMembershipWithInvalidRolesProvider in Organic groups 8

Provides test data for saving a membership with invalid roles.

Return value

array An array of test data, each item is an associative array of role metadata with the following keys:

  • group: the group to associate with the role. Can be 'test_group', 'different_bundle', or 'different_entity_type'.
  • role_name: the role name.

File

tests/src/Kernel/Entity/OgMembershipTest.php, line 511

Class

OgMembershipTest
Tests the OgMembership entity.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

public function saveMembershipWithInvalidRolesProvider() : array {
  return [
    // A membership can not be saved for an anonymous user.
    [
      [
        [
          'group' => 'test_group',
          'role_name' => OgRoleInterface::ANONYMOUS,
        ],
      ],
    ],
    // A membership with multiple roles can not be saved if any of the roles
    // is for an anonymous user.
    [
      [
        [
          'group' => 'test_group',
          'role_name' => OgRoleInterface::ADMINISTRATOR,
        ],
        [
          'group' => 'test_group',
          'role_name' => 'custom_role',
        ],
        [
          'group' => 'test_group',
          'role_name' => OgRoleInterface::ANONYMOUS,
        ],
      ],
    ],
    // A membership can not be saved when one of the roles references a
    // different bundle.
    [
      [
        [
          'group' => 'test_group',
          'role_name' => OgRoleInterface::ADMINISTRATOR,
        ],
        [
          'group' => 'different_bundle',
          'role_name' => OgRoleInterface::ADMINISTRATOR,
        ],
      ],
    ],
    // A membership can not be saved when one of the roles references a
    // different entity type.
    [
      [
        [
          'group' => 'test_group',
          'role_name' => OgRoleInterface::ADMINISTRATOR,
        ],
        [
          'group' => 'different_entity_type',
          'role_name' => OgRoleInterface::ADMINISTRATOR,
        ],
      ],
    ],
  ];
}