You are here

public function GroupManagerTest::testGroupUserMembershipsFromUserAttr in Lightweight Directory Access Protocol (LDAP) 8.4

Test group users membership from user attribute.

File

ldap_servers/tests/src/Kernel/GroupManagerTest.php, line 57

Class

GroupManagerTest
Group manager test.

Namespace

Drupal\Tests\ldap_servers\Kernel

Code

public function testGroupUserMembershipsFromUserAttr() : void {

  /** @var \Drupal\ldap_servers\LdapGroupManager $group_manager */
  $group_manager = $this->container
    ->get('ldap.group_manager');
  $memberships = [
    'cn=group1,ou=people,dc=hogwarts,dc=edu',
    'cn=group2,ou=people,dc=hogwarts,dc=edu',
  ];
  $entry = new Entry('cn=hpotter,ou=people,dc=hogwarts,dc=edu', [
    'cn' => [
      0 => 'hpotter',
    ],
    'mail' => [
      0 => 'hpotter@hogwarts.edu',
      1 => 'hpotter@students.hogwarts.edu',
    ],
    'memberOf' => $memberships,
  ]);
  $group_manager
    ->setServer($this->server);
  $result = $group_manager
    ->groupUserMembershipsFromUserAttr($entry);
  self::assertEquals($memberships, $result);
}