You are here

public function EntityCollectorTest::testCollectForAccount in Simple OAuth (OAuth2) & OpenID Connect 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Unit/EntityCollectorTest.php \Drupal\Tests\simple_oauth\Unit\EntityCollectorTest::testCollectForAccount()
  2. 8.2 tests/src/Unit/EntityCollectorTest.php \Drupal\Tests\simple_oauth\Unit\EntityCollectorTest::testCollectForAccount()
  3. 5.x tests/src/Unit/EntityCollectorTest.php \Drupal\Tests\simple_oauth\Unit\EntityCollectorTest::testCollectForAccount()

@covers ::collectForAccount

File

tests/src/Unit/EntityCollectorTest.php, line 49

Class

EntityCollectorTest
@coversDefaultClass \Drupal\simple_oauth\ExpiredCollector @group simple_oauth

Namespace

Drupal\Tests\simple_oauth\Unit

Code

public function testCollectForAccount() {
  list($expired_collector, $token_query, , , $client_storage) = $this
    ->buildProphecies();
  $account = $this
    ->prophesize(AccountInterface::class);
  $account
    ->id()
    ->willReturn(22);
  $token_query
    ->condition('auth_user_id', 22)
    ->shouldBeCalledTimes(1);
  $token_query
    ->condition('bundle', 'refresh_token', '!=')
    ->shouldBeCalledTimes(1);
  $client_storage
    ->loadByProperties([
    'user_id' => 22,
  ])
    ->shouldBeCalledTimes(1);
  $token_query
    ->condition('client', 6)
    ->shouldBeCalledTimes(1);
  $tokens = $expired_collector
    ->collectForAccount($account
    ->reveal());
  $this
    ->assertArrayEquals([
    1,
    52,
  ], array_map(function ($entity) {
    return $entity
      ->id();
  }, $tokens));
}