You are here

public function AnonymousPrivateTempStoreTest::testAnonymousCanUsePrivateTempStoreSet in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/TempStore/AnonymousPrivateTempStoreTest.php \Drupal\KernelTests\Core\TempStore\AnonymousPrivateTempStoreTest::testAnonymousCanUsePrivateTempStoreSet()
  2. 10 core/tests/Drupal/KernelTests/Core/TempStore/AnonymousPrivateTempStoreTest.php \Drupal\KernelTests\Core\TempStore\AnonymousPrivateTempStoreTest::testAnonymousCanUsePrivateTempStoreSet()

Tests anonymous can use the PrivateTempStore.

File

core/tests/Drupal/KernelTests/Core/TempStore/AnonymousPrivateTempStoreTest.php, line 58

Class

AnonymousPrivateTempStoreTest
Tests the PrivateTempStore for anonymous users.

Namespace

Drupal\KernelTests\Core\TempStore

Code

public function testAnonymousCanUsePrivateTempStoreSet() {
  $this->tempStore
    ->set('foo', 'bar');
  $metadata1 = $this->tempStore
    ->getMetadata('foo');
  $this
    ->assertEquals('bar', $this->tempStore
    ->get('foo'));
  $this
    ->assertNotEmpty($metadata1
    ->getOwnerId());
  $this->tempStore
    ->set('foo', 'bar2');
  $metadata2 = $this->tempStore
    ->getMetadata('foo');
  $this
    ->assertEquals('bar2', $this->tempStore
    ->get('foo'));
  $this
    ->assertNotEmpty($metadata2
    ->getOwnerId());
  $this
    ->assertEquals($metadata2
    ->getOwnerId(), $metadata1
    ->getOwnerId());
}