You are here

public function LTIToolProviderTest::testTimestampDuplicateNonce in LTI Tool Provider 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/LTIToolProviderTest.php \Drupal\Tests\lti_tool_provider\Unit\LTIToolProviderTest::testTimestampDuplicateNonce()

Tests duplicate nonces.

@covers ::timestampNonceHandler @covers ::__construct

File

tests/src/Unit/LTIToolProviderTest.php, line 410

Class

LTIToolProviderTest
LTIToolProvider unit tests.

Namespace

Drupal\Tests\lti_tool_provider\Unit

Code

public function testTimestampDuplicateNonce() {
  $entityTypeManager = $this->entityTypeManager;
  $this->provider->consumer_key = '';
  $this->provider->nonce = uniqid();
  $this->provider->timestamp = time();
  $query = $this
    ->createMock('Drupal\\Core\\Entity\\Query\\QueryInterface');
  $query
    ->expects($this
    ->once())
    ->method('condition')
    ->will($this
    ->returnValue($query));
  $query
    ->expects($this
    ->once())
    ->method('execute')
    ->will($this
    ->returnValue([
    $this
      ->createMock('Drupal\\Core\\Entity\\EntityInterface'),
  ]));
  $storage = $this
    ->createMock('Drupal\\Core\\Entity\\EntityStorageInterface');
  $storage
    ->expects($this
    ->once())
    ->method('getQuery')
    ->will($this
    ->returnValue($query));
  $entityTypeManager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->will($this
    ->returnValue($storage));
  $provider = new LTIToolProvider($this->configFactory, $entityTypeManager, $this->loggerFactory, $this->eventDispatcher);
  $expected = OAUTH_BAD_NONCE;
  $actual = $provider
    ->timestampNonceHandler($this->provider);
  $this
    ->assertEquals($expected, $actual);
}