You are here

public function GroupMembershipManagerTest::testGetGroupIds in Organic groups 8

Tests retrieval of groups IDs that are associated with given group content.

@covers ::getGroupIds @dataProvider groupContentProvider

Parameters

string $group_type_id: Optional group type ID to be passed as an argument to the method under test.

string $group_bundle: Optional group bundle to be passed as an argument to the method under test.

array $expected: An array containing the expected results to be returned.

File

tests/src/Kernel/Entity/GroupMembershipManagerTest.php, line 183

Class

GroupMembershipManagerTest
Tests retrieving groups associated with a given group content.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

public function testGetGroupIds($group_type_id, $group_bundle, array $expected) {
  $result = $this->membershipManager
    ->getGroupIds($this->groupContent, $group_type_id, $group_bundle);

  // Check that the correct number of results is returned.
  $this
    ->assertEquals(count($expected, COUNT_RECURSIVE), count($result, COUNT_RECURSIVE));

  // Check that all expected results are returned.
  foreach ($expected as $expected_type => $expected_keys) {
    foreach ($expected_keys as $expected_key) {
      $this
        ->assertTrue(in_array($this->groups[$expected_type][$expected_key]
        ->id(), $result[$expected_type]));
    }
  }
}