You are here

protected function PrivateTempStoreTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/tests/src/Unit/PrivateTempStoreTest.php \Drupal\Tests\user\Unit\PrivateTempStoreTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/user/tests/src/Unit/PrivateTempStoreTest.php, line 73
Contains \Drupal\Tests\user\Unit\PrivateTempStoreTest.

Class

PrivateTempStoreTest
@coversDefaultClass \Drupal\user\PrivateTempStore @group user

Namespace

Drupal\Tests\user\Unit

Code

protected function setUp() {
  parent::setUp();
  $this->keyValue = $this
    ->getMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreExpirableInterface');
  $this->lock = $this
    ->getMock('Drupal\\Core\\Lock\\LockBackendInterface');
  $this->currentUser = $this
    ->getMock('Drupal\\Core\\Session\\AccountProxyInterface');
  $this->currentUser
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn(1);
  $this->requestStack = new RequestStack();
  $request = Request::createFromGlobals();
  $this->requestStack
    ->push($request);
  $this->tempStore = new PrivateTempStore($this->keyValue, $this->lock, $this->currentUser, $this->requestStack, 604800);
  $this->ownObject = (object) array(
    'data' => 'test_data',
    'owner' => $this->currentUser
      ->id(),
    'updated' => (int) $request->server
      ->get('REQUEST_TIME'),
  );

  // Clone the object but change the owner.
  $this->otherObject = clone $this->ownObject;
  $this->otherObject->owner = 2;
}