You are here

public function CasPropertyBagTest::testGetUsername in CAS 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/CasPropertyBagTest.php \Drupal\Tests\cas\Unit\CasPropertyBagTest::testGetUsername()

Test getting the username.

@covers ::getUsername

File

tests/src/Unit/CasPropertyBagTest.php, line 76

Class

CasPropertyBagTest
CasPropertyBag unit tests.

Namespace

Drupal\Tests\cas\Unit

Code

public function testGetUsername() {
  $name = $this
    ->randomMachineName(8);
  $bag = new CasPropertyBag($name);
  $reflection = new \ReflectionClass($bag);
  $property = $reflection
    ->getProperty('username');
  $property
    ->setAccessible(TRUE);
  $new_name = $this
    ->randomMachineName(8);
  $property
    ->setValue($bag, $new_name);
  $this
    ->assertEquals($new_name, $bag
    ->getUsername());
  $this
    ->assertEquals($name, $bag
    ->getOriginalUsername());
}