class SwitchUserTokenProcessorTest extends TestCase
{ public function testProcessor() { $originalToken =
new UsernamePasswordToken(new InMemoryUser('original_user', 'password',
['ROLE_SUPER_ADMIN'
]), 'provider',
['ROLE_SUPER_ADMIN'
]);
$switchUserToken =
new SwitchUserToken(new InMemoryUser('user', 'passsword',
['ROLE_USER'
]), 'provider',
['ROLE_USER'
],
$originalToken);
$tokenStorage =
$this->
createMock(TokenStorageInterface::
class);
$tokenStorage->
method('getToken'
)->
willReturn($switchUserToken);
$processor =
new SwitchUserTokenProcessor($tokenStorage);
$record = RecordFactory::
create();
$record =
$processor($record);
$expected =
[ 'impersonator_token' =>
[ 'authenticated' => true,
'roles' =>
['ROLE_SUPER_ADMIN'
],
'user_identifier' => 'original_user',
],
];