public function CasPropertyBagTest::testGetUsername in CAS 8
Same name and namespace in other branches
- 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\UnitCode
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());
}