/**
* @dataProvider getTestParameters
*/
public function testSwitchUser($originalUser,
$targetUser,
$expectedUser,
$expectedStatus) { $client =
$this->
createAuthenticatedClient($originalUser,
['root_config' => 'switchuser.yml'
]);
$client->
request('GET', '/profile?_switch_user='.
$targetUser);
$this->
assertEquals($expectedStatus,
$client->
getResponse()->
getStatusCode());
$this->
assertEquals($expectedUser,
$client->
getProfile()->
getCollector('security'
)->
getUser());
} public function testSwitchedUserCanSwitchToOther() { $client =
$this->
createAuthenticatedClient('user_can_switch'
);
$client->
request('GET', '/profile?_switch_user=user_cannot_switch_1'
);
$client->
request('GET', '/profile?_switch_user=user_cannot_switch_2'
);
$this->
assertEquals(200,
$client->
getResponse()->
getStatusCode());
$this->
assertEquals('user_cannot_switch_2',
$client->
getProfile()->
getCollector('security'
)->
getUser());
}