You are here

protected function UserGroupAccessResolverTest::getTestEntityProperties in Organic groups 8

Returns properties used to create mock test entities.

This is used to facilitate referring to entities in data providers. Since a data provider is called before the test setup runs, we cannot return actual entities in the data provider. Instead the data provider can refer to these test entities by ID, and the actual entity mocks will be generated in the test setup.

The test groups should be declared first, the group content last.

Return value

array An array of entity metadata, keyed by test entity ID. Each item is an array with the following keys:

  • type (required): The entity type ID.
  • bundle (required): The entity bundle.
  • group (optional): Whether or not the entity is a group.
  • group_content (optional): An array containing IDs of groups this group content belongs to.

Overrides OgGroupResolverTestBase::getTestEntityProperties

File

tests/src/Unit/Plugin/OgGroupResolver/UserGroupAccessResolverTest.php, line 98

Class

UserGroupAccessResolverTest
Tests the UserGroupAccessResolver plugin.

Namespace

Drupal\Tests\og\Unit\Plugin\OgGroupResolver

Code

protected function getTestEntityProperties() {
  return [
    // Some test groups to which the current user has access.
    'group-access-0' => [
      'type' => 'node',
      'bundle' => 'group',
      'group' => TRUE,
      'current_user_has_access' => TRUE,
    ],
    'group-access-1' => [
      'type' => 'taxonomy_term',
      'bundle' => 'assembly',
      'group' => TRUE,
      'current_user_has_access' => TRUE,
    ],
    // Some test groups to which the current user does not have access.
    'group-noaccess-0' => [
      'type' => 'entity_test',
      'bundle' => 'cluster',
      'group' => TRUE,
      'current_user_has_access' => FALSE,
    ],
    'group-noaccess-1' => [
      'type' => 'block_content',
      'bundle' => 'flock',
      'group' => TRUE,
      'current_user_has_access' => FALSE,
    ],
  ];
}