function SharedTempStoreTest::testLegacyConstructor

@group legacy

File

core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php, line 381

Class

SharedTempStoreTest
@coversDefaultClass \Drupal\Core\TempStore\SharedTempStore @group TempStore

Namespace

Drupal\Tests\Core\TempStore

Code

public function testLegacyConstructor() {
    $this->expectDeprecation('Calling Drupal\\Core\\TempStore\\SharedTempStore::__construct() without the $current_user argument is deprecated in drupal:9.2.0 and will be required in drupal:10.0.0. See https://www.drupal.org/node/3006268');
    $container = new ContainerBuilder();
    $current_user = $this->createMock(AccountProxyInterface::class);
    $container->set('current_user', $current_user);
    \Drupal::setContainer($container);
    $store = new SharedTempStore($this->keyValue, $this->lock, 2, $this->requestStack, 1000);
    $reflection_class = new \ReflectionClass(SharedTempStore::class);
    $current_user_property = $reflection_class->getProperty('currentUser');
    $current_user_property->setAccessible(TRUE);
    $this->assertSame($current_user, $current_user_property->getValue($store));
    $expire_property = $reflection_class->getProperty('expire');
    $expire_property->setAccessible(TRUE);
    $this->assertSame(1000, $expire_property->getValue($store));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.