function SharedTempStoreTest::testLegacyFactoryConstructor

@group legacy @covers \Drupal\Core\TempStore\SharedTempStoreFactory::__construct

File

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

Class

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

Namespace

Drupal\Tests\Core\TempStore

Code

public function testLegacyFactoryConstructor() {
    $this->expectDeprecation('Calling Drupal\\Core\\TempStore\\SharedTempStoreFactory::__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);
    $key_value_factory = $this->prophesize(KeyValueExpirableFactoryInterface::class);
    $store = new SharedTempStoreFactory($key_value_factory->reveal(), $this->lock, $this->requestStack, 1000);
    $reflection_class = new \ReflectionClass(SharedTempStoreFactory::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.