You are here

public function ServerTests::testRemoveUnchangedAttributes in Lightweight Directory Access Protocol (LDAP) 8.3

Test removing unchanged attributes.

File

ldap_servers/tests/src/Unit/ServerTests.php, line 67

Class

ServerTests
@coversDefaultClass \Drupal\ldap_servers\Entity\Server @group ldap

Namespace

Drupal\Tests\ldap_servers\Unit

Code

public function testRemoveUnchangedAttributes() {
  $existing_data = [
    'cn' => [
      0 => 'hpotter',
      'count' => 1,
    ],
    'memberof' => [
      0 => 'cn=gryffindor,ou=groups,dc=hogwarts,dc=edu',
      1 => 'cn=students,ou=groups,dc=hogwarts,dc=edu',
      2 => 'cn=honors students,ou=groups,dc=hogwarts,dc=edu',
      'count' => 3,
    ],
    'count' => 2,
  ];
  $new_data = [
    'cn' => 'hpotter',
    'test_example_value' => 'Test1',
    'memberOf' => [
      'Group1',
    ],
  ];
  $result = Server::removeUnchangedAttributes($new_data, $existing_data);
  $result_expected = [
    'test_example_value' => 'Test1',
    'memberOf' => [
      'Group1',
    ],
  ];
  $this
    ->assertEquals($result_expected, $result);
}