function PrivateTempStoreTest::setUp
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php \Drupal\Tests\Core\TempStore\PrivateTempStoreTest::setUp()
- 8.9.x core/modules/user/tests/src/Unit/PrivateTempStoreTest.php \Drupal\Tests\user\Unit\PrivateTempStoreTest::setUp()
- 8.9.x core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php \Drupal\Tests\Core\TempStore\PrivateTempStoreTest::setUp()
- 11.x core/tests/Drupal/Tests/Core/TempStore/PrivateTempStoreTest.php \Drupal\Tests\Core\TempStore\PrivateTempStoreTest::setUp()
Overrides UnitTestCase::setUp
File
-
core/
tests/ Drupal/ Tests/ Core/ TempStore/ PrivateTempStoreTest.php, line 72
Class
- PrivateTempStoreTest
- @coversDefaultClass \Drupal\Core\TempStore\PrivateTempStore @group TempStore
Namespace
Drupal\Tests\Core\TempStoreCode
protected function setUp() : void {
parent::setUp();
$this->keyValue = $this->createMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreExpirableInterface');
$this->lock = $this->createMock('Drupal\\Core\\Lock\\LockBackendInterface');
$this->currentUser = $this->createMock('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) [
'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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.