Skip to content

Commit

Permalink
Increase coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Mar 17, 2023
1 parent 43d33a0 commit 4b5cc23
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,37 @@ public function testImpersonate()
$this->assertNull($controller->getRequest()->getSession()->read('AuthImpersonate'));
}

/**
* test that impersonate() can handle identities with array data within them.
*
* @return void
*/
public function testImpersonateDecoratorIgnored()
{
$impersonator = ['username' => 'mariano'];
$impersonated = new ArrayObject(['username' => 'larry']);

$this->request->getSession()->write('Auth', $impersonator);
$this->service->authenticate($this->request);
$identity = new Identity($impersonator);
$request = $this->request
->withAttribute('identity', $identity)
->withAttribute('authentication', $this->service);
$controller = new Controller($request, $this->response);
$registry = new ComponentRegistry($controller);
$component = new AuthenticationComponent($registry);

$this->assertEquals($impersonator, $controller->getRequest()->getSession()->read('Auth'));
$this->assertNull($controller->getRequest()->getSession()->read('AuthImpersonate'));

$component->impersonate($impersonated);
$this->assertEquals($impersonated, $controller->getRequest()->getSession()->read('Auth'));
$this->assertEquals(new ArrayObject($impersonator), $controller->getRequest()->getSession()->read('AuthImpersonate'));

$component->stopImpersonating();
$this->assertNull($controller->getRequest()->getSession()->read('AuthImpersonate'));
}

/**
* testImpersonateNoIdentity
*
Expand Down

0 comments on commit 4b5cc23

Please sign in to comment.