createAuthenticatedClient example

use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Security\Http\Firewall\SwitchUserListener;

class SwitchUserTest extends AbstractWebTestCase
{
    /** * @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');

        
Home | Imprint | This part of the site doesn't use cookies.