public function PathContextTest::testGetIdentity in Acquia Lift Connector 8
Tests the getIdentity() method.
@covers ::setIdentityByUser @covers ::getIdentity
@dataProvider providerTestGetIdentity
Parameters
string $query_parameter_string:
boolean $capture_identity:
boolean $do_set_user:
array $expect_identity:
File
- tests/
src/ Unit/ Service/ Context/ PathContextTest.php, line 176 - Contains \Drupal\Tests\acquia_lift\Service\Context\PathContextTest.
Class
- PathContextTest
- PathContextTest Test.
Namespace
Drupal\Tests\acquia_lift\Service\ContextCode
public function testGetIdentity($query_parameter_string, $capture_identity, $do_set_user, $expect_identity) {
$this->requestStack
->expects($this
->once())
->method('getCurrentRequest')
->willReturn($this->request);
$this->request
->expects($this
->once())
->method('getQueryString')
->willReturn($query_parameter_string);
$credential_settings = $this
->getValidCredentialSettings();
$identity_settings = $this
->getValidIdentitySettings();
$identity_settings['capture_identity'] = $capture_identity;
$this->settings
->expects($this
->at(0))
->method('get')
->with('credential')
->willReturn($credential_settings);
$this->settings
->expects($this
->at(1))
->method('get')
->with('identity')
->willReturn($identity_settings);
$path_context = new PathContext($this->configFactory, $this->currentPathStack, $this->requestStack, $this->pathMatcher);
if ($do_set_user) {
$user = $this
->getMock('Drupal\\user\\UserInterface');
$user
->expects($this
->exactly((int) $capture_identity))
->method('getEmail')
->willReturn('a_user_email');
$path_context
->setIdentityByUser($user);
}
$identity = $path_context
->getIdentity();
$this
->assertEquals($expect_identity, $identity);
}