You are here

public function OpenIdConnectSessionTest::testSaveDestination in OpenID Connect / OAuth client 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/OpenIdConnectSessionTest.php \Drupal\Tests\openid_connect\Unit\OpenIdConnectSessionTest::testSaveDestination()

Test the save destination method.

File

tests/src/Unit/OpenIdConnectSessionTest.php, line 73

Class

OpenIdConnectSessionTest
@coversDefaultClass \Drupal\openid_connect\OpenIDConnectSession @group openid_connect

Namespace

Drupal\Tests\openid_connect\Unit

Code

public function testSaveDestination() : void {

  // Get the expected session array.
  $expectedSession = $this
    ->getExpectedSessionArray(self::TEST_PATH, self::TEST_QUERY);

  // Mock the getPath method for the current path service.
  $this->currentPath
    ->expects($this
    ->once())
    ->method('getPath')
    ->willReturn(self::TEST_PATH);

  // Create a new OpenIDConnectSession class.
  $session = new OpenIDConnectSession($this->currentPath, $this->requestStack);

  // Call the saveDestination() method.
  $session
    ->saveDestination();

  // Assert the $_SESSOIN global matches our expectation.
  $this
    ->assertArrayEquals($expectedSession, $_SESSION);
}