public function BynderApiUnitTest::testHasAccessToken in Bynder 8
Same name and namespace in other branches
- 8.3 tests/src/Unit/BynderApiUnitTest.php \Drupal\Tests\bynder\Unit\BynderApiUnitTest::testHasAccessToken()
- 8.2 tests/src/Unit/BynderApiUnitTest.php \Drupal\Tests\bynder\Unit\BynderApiUnitTest::testHasAccessToken()
- 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\UnitCode
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 = $this
->getMock(BynderApi::class, [
'__call',
], [
$config
->reveal(),
$logger
->reveal(),
$session
->reveal(),
$state
->reveal(),
$cache
->reveal(),
$time
->reveal(),
]);
$this
->assertEquals($expected, $api
->hasAccessToken());
}