You are here

protected function GetUserGroupsTest::assertGroupExistsInResults in Organic groups 8

Asserts whether a group ID exists in some results.

Assumes entity_type is used.

Parameters

\Drupal\entity_test\Entity\EntityTest $group_to_check: The group entity to check.

array $results: Array keyed by the entity type, and with the group entities as values.

2 calls to GetUserGroupsTest::assertGroupExistsInResults()
GetUserGroupsTest::testOtherGroups in tests/src/Kernel/Entity/GetUserGroupsTest.php
Tests other groups users are added to.
GetUserGroupsTest::testOwnerGroupsOnly in tests/src/Kernel/Entity/GetUserGroupsTest.php
Tests group owners have the correct groups.

File

tests/src/Kernel/Entity/GetUserGroupsTest.php, line 321

Class

GetUserGroupsTest
Tests getting the memberships of an entity.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

protected function assertGroupExistsInResults(EntityTest $group_to_check, array $results) {
  $found = FALSE;
  foreach ($results['entity_test'] as $group) {
    if ($group
      ->id() == $group_to_check
      ->id()) {
      $found = TRUE;
      break;
    }
  }
  $this
    ->assertTrue($found);
}