You are here

public function OpenIDConnectAuthmapTest::testDeleteAssociationMethod in OpenID Connect / OAuth client 8

Test the deleteAssociationMethod.

@dataProvider getDeleteAssociationParameters

Parameters

string|null $client: The client name to test or an empty client.

File

tests/src/Unit/OpenIDConnectAuthmapTest.php, line 153

Class

OpenIDConnectAuthmapTest
Test the OpenIdConnectAuthmap class.

Namespace

Drupal\Tests\openid_connect\Unit

Code

public function testDeleteAssociationMethod(?string $client) : void {
  $deleteQuery = $this
    ->createMock(Delete::class);
  if (!empty($client)) {
    $deleteQuery
      ->expects($this
      ->exactly(2))
      ->method('condition')
      ->withConsecutive([
      'uid',
      self::USER_ID,
      '=',
    ], [
      'client_name',
      $client,
      '=',
    ])
      ->willReturnSelf();
  }
  else {
    $deleteQuery
      ->expects($this
      ->once())
      ->method('condition')
      ->with('uid', self::USER_ID, '=')
      ->willReturnSelf();
  }
  $deleteQuery
    ->expects($this
    ->once())
    ->method('execute')
    ->willReturn(1);
  $this->connection
    ->expects($this
    ->once())
    ->method('delete')
    ->with('openid_connect_authmap')
    ->willReturn($deleteQuery);
  $authMapClass = new OpenIDConnectAuthmap($this->connection, $this->entityTypeManager);
  $authMapClass
    ->deleteAssociation(self::USER_ID, $client);
}