You are here

public function TokenTest::testReversal in Lightweight Directory Access Protocol (LDAP) 8.4

Test reversal.

File

ldap_servers/tests/src/Unit/TokenTest.php, line 111

Class

TokenTest
@coversDefaultClass \Drupal\ldap_servers\Processor\TokenProcessor @group ldap

Namespace

Drupal\Tests\ldap_servers\Unit

Code

public function testReversal() : void {

  // Test regular reversal (2 elements) at beginning.
  $dc = $this->processor
    ->ldapEntryReplacementsForDrupalAccount($this->ldapEntry, '[dc:reverse:0]');
  self::assertEquals('edu', $dc);

  // Test single element reversion.
  $ou = $this->processor
    ->ldapEntryReplacementsForDrupalAccount($this->ldapEntry, '[cn:reverse:0]');
  self::assertEquals('hpotter', $ou);

  // Test 3 element reversion at end.
  $ou2 = $this->processor
    ->ldapEntryReplacementsForDrupalAccount($this->ldapEntry, '[ou:reverse:2]');
  self::assertEquals('Gryffindor', $ou2);
}