You are here

public function OgMembershipTest::testMemberRole in Organic groups 8

Tests that membership has "member" role when roles are retrieved.

@covers ::getRoles

File

tests/src/Kernel/Entity/OgMembershipTest.php, line 760

Class

OgMembershipTest
Tests the OgMembership entity.

Namespace

Drupal\Tests\og\Kernel\Entity

Code

public function testMemberRole() {
  $membership = Og::createMembership($this->group, $this->user);
  $membership
    ->setState(OgMembershipInterface::STATE_ACTIVE)
    ->save();
  $membership = $this->entityTypeManager
    ->getStorage('og_membership')
    ->loadUnchanged($membership
    ->id());
  $roles = $membership
    ->getRoles();
  $role = current($roles);
  $this
    ->assertEquals(1, count($roles));
  $this
    ->assertEquals(OgRoleInterface::AUTHENTICATED, $role
    ->getName());
}