You are here

protected function RouteGroupContentResolverTest::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/RouteGroupContentResolverTest.php, line 43

Class

RouteGroupContentResolverTest
Tests the RouteGroupContentResolver plugin.

Namespace

Drupal\Tests\og\Unit\Plugin\OgGroupResolver

Code

protected function getTestEntityProperties() {
  return [
    // A 'normal' test group.
    'group-0' => [
      'type' => 'node',
      'bundle' => 'group',
      'group' => TRUE,
    ],
    // A test group that is also group content for group-0.
    'group-1' => [
      'type' => 'taxonomy_term',
      'bundle' => 'assembly',
      'group' => TRUE,
      'group_content' => [
        'group-0',
      ],
    ],
    // Group content belonging to group-0.
    'group_content-0' => [
      'type' => 'entity_test',
      'bundle' => 'content',
      'group_content' => [
        'group-0',
      ],
    ],
    // Group content belonging to group-1.
    'group_content-1' => [
      'type' => 'node',
      'bundle' => 'article',
      'group_content' => [
        'group-1',
      ],
    ],
    // Group content belonging to both groups.
    'group_content-2' => [
      'type' => 'taxonomy_term',
      'bundle' => 'tags',
      'group_content' => [
        'group-0',
        'group-1',
      ],
    ],
    // An entity that is not a group nor group content.
    'non_group' => [
      'type' => 'entity_test',
      'bundle' => 'non_group',
    ],
  ];
}