LegacyStateTest.php

Same filename in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/State/LegacyStateTest.php

Namespace

Drupal\KernelTests\Core\State

File

core/tests/Drupal/KernelTests/Core/State/LegacyStateTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\KernelTests\Core\State;

use Drupal\KernelTests\KernelTestBase;

/**
 * Tests the legacy state deprecations.
 *
 * @group system
 * @group legacy
 * @coversDefaultClass \Drupal\Core\State\State
 */
class LegacyStateTest extends KernelTestBase {
    
    /**
     * @covers ::get
     * @covers ::set
     */
    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());
    }

}

Classes

Title Deprecated Summary
LegacyStateTest Tests the legacy state deprecations.

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