You are here

public function PreviewLinkStorageTest::testRegenerateToken in Preview Link 8

Same name and namespace in other branches
  1. 2.x tests/src/Kernel/PreviewLinkStorageTest.php \Drupal\Tests\preview_link\Kernel\PreviewLinkStorageTest::testRegenerateToken()
  2. 2.0.x tests/src/Kernel/PreviewLinkStorageTest.php \Drupal\Tests\preview_link\Kernel\PreviewLinkStorageTest::testRegenerateToken()

Ensure we can re-generate a token.

File

tests/src/Kernel/PreviewLinkStorageTest.php, line 68

Class

PreviewLinkStorageTest
Preview link form test.

Namespace

Drupal\Tests\preview_link\Kernel

Code

public function testRegenerateToken() {
  $preview_link = $this->storage
    ->createPreviewLinkForEntity($this->node);
  $current_token = $preview_link
    ->getToken();
  $current_timestamp = $preview_link
    ->getGeneratedTimestamp();

  // Regenerate and ensure it changed.
  $preview_link
    ->regenerateToken(TRUE);
  $preview_link
    ->save();
  $this
    ->assertNotEquals($current_token, $preview_link
    ->getToken());
  $this
    ->assertNotEquals($current_timestamp, $preview_link
    ->getGeneratedTimestamp());
}