You are here

public function BynderApiUnitTest::testHasAccessToken in Bynder 8.3

Same name and namespace in other branches
  1. 8 tests/src/Unit/BynderApiUnitTest.php \Drupal\Tests\bynder\Unit\BynderApiUnitTest::testHasAccessToken()
  2. 8.2 tests/src/Unit/BynderApiUnitTest.php \Drupal\Tests\bynder\Unit\BynderApiUnitTest::testHasAccessToken()
  3. 4.0.x tests/src/Unit/BynderApiUnitTest.php \Drupal\Tests\bynder\Unit\BynderApiUnitTest::testHasAccessToken()

@covers ::hasAccessToken

@dataProvider providerHasAccessToken

File

tests/src/Unit/BynderApiUnitTest.php, line 26

Class

BynderApiUnitTest
@coversDefaultClass \Drupal\bynder\BynderApi

Namespace

Drupal\Tests\bynder\Unit

Code

public function testHasAccessToken($session_data, $valid_hash, $state_times, $expected) {
  $session = $this
    ->prophesize(SessionInterface::class);
  $session
    ->get('bynder', [])
    ->willReturn($session_data)
    ->shouldBeCalledTimes(1);
  $state = $this
    ->prophesize(StateInterface::class);
  $state
    ->get('bynder_config_hash')
    ->willReturn($valid_hash)
    ->shouldBeCalledTimes($state_times);
  $logger = $this
    ->prophesize(LoggerChannelFactoryInterface::class);
  $config = $this
    ->prophesize(ConfigFactoryInterface::class);
  $cache = $this
    ->prophesize(CacheBackendInterface::class);
  $time = $this
    ->prophesize(TimeInterface::class);
  $api = new BynderApi($config
    ->reveal(), $logger
    ->reveal(), $session
    ->reveal(), $state
    ->reveal(), $cache
    ->reveal(), $time
    ->reveal());
  $this
    ->assertEquals($expected, $api
    ->hasAccessToken());
}