public function GetUserGroupsTest::testOwnerGroupsOnly in Organic groups 8
Tests group owners have the correct groups.
@todo Convert Og::isMember() calls to $this->membershipManager->isMember().
File
- tests/
src/ Kernel/ Entity/ GetUserGroupsTest.php, line 137
Class
- GetUserGroupsTest
- Tests getting the memberships of an entity.
Namespace
Drupal\Tests\og\Kernel\EntityCode
public function testOwnerGroupsOnly() {
$actual = $this->membershipManager
->getUserGroups($this->user1
->id());
$this
->assertCount(1, $actual['entity_test']);
$this
->assertGroupExistsInResults($this->group1, $actual);
// Also check isMember.
$this
->assertTrue(Og::isMember($this->group1, $this->user1));
$this
->assertFalse(Og::isMember($this->group1, $this->user2));
$actual = $this->membershipManager
->getUserGroups($this->user2
->id());
$this
->assertCount(1, $actual['entity_test']);
$this
->assertGroupExistsInResults($this->group2, $actual);
// Also check isMember.
$this
->assertTrue(Og::isMember($this->group2, $this->user2));
$this
->assertFalse(Og::isMember($this->group2, $this->user1));
}