function LegacyStateTest::testDeprecatedState

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/State/LegacyStateTest.php \Drupal\KernelTests\Core\State\LegacyStateTest::testDeprecatedState()

@covers ::get @covers ::set

File

core/tests/Drupal/KernelTests/Core/State/LegacyStateTest.php, line 22

Class

LegacyStateTest
Tests the legacy state deprecations.

Namespace

Drupal\KernelTests\Core\State

Code

public function testDeprecatedState() : void {
    $state = $this->container
        ->get('state');
    $this->expectDeprecation('The \'system.css_js_query_string\' state is deprecated in drupal:10.2.0. Use \\Drupal\\Core\\Asset\\AssetQueryStringInterface::get() and ::reset() instead. See https://www.drupal.org/node/3358337.');
    $state->set('system.css_js_query_string', 'foo');
    $this->expectDeprecation('The \'system.css_js_query_string\' state is deprecated in drupal:10.2.0. Use \\Drupal\\Core\\Asset\\AssetQueryStringInterface::get() and ::reset() instead. See https://www.drupal.org/node/3358337.');
    $this->assertEquals('foo', $state->get('system.css_js_query_string'));
    $this->assertEquals('foo', \Drupal::service('asset.query_string')->get());
}

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