By sapnil_biswas on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
12.1.x
Introduced in version:
12.1.0
Issue links:
Description:
Problem/Motivation
In Drupal 12.1.0, kernel tests no longer use a synthetic in-memory key/value store, instead relying on the standard database key/value factory. Accessing $this->keyValue directly on KernelTestBase is deprecated and will be removed in Drupal 13.0.0.
Proposed resolution
Access the key/value service via dependency injection or the container instead of $this->keyValue
Before
$value = $this->keyValue->get('my_collection')->get('my_key');
After
$value = $this->container->get('keyvalue')->get('my_collection')->get('my_key');
// Or:
$value = \Drupal::service('keyvalue')->get('my_collection')->get('my_key');