diff -u b/core/modules/config/src/Tests/ConfigEntityTest.php b/core/modules/config/src/Tests/ConfigEntityTest.php --- b/core/modules/config/src/Tests/ConfigEntityTest.php +++ b/core/modules/config/src/Tests/ConfigEntityTest.php @@ -35,7 +35,7 @@ public function testCRUD() { $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); // Verify default properties on a newly created empty entity. - $empty = \Drupal::entityTypeManager()->getStorage('config_test')->create(); + $storage = \Drupal::entityTypeManager()->getStorage('config_test'); $this->assertTrue($empty->uuid()); $this->assertIdentical($empty->label, NULL); $this->assertIdentical($empty->style, NULL); @@ -76,7 +76,7 @@ } // Verify that an entity with an empty ID string is considered empty, too. - $empty_id = \Drupal::entityTypeManager()->getStorage('config_test')->create([ + $empty_id = $storage->create([ 'id' => '', ]); $this->assertIdentical($empty_id->isNew(), TRUE); @@ -89,7 +89,7 @@ } // Verify properties on a newly created entity. - $config_test = \Drupal::entityTypeManager()->getStorage('config_test')->create($expected = [ + $config_test = $storage->create($expected = [ 'id' => $this->randomMachineName(), 'label' => $this->randomString(), 'style' => $this->randomMachineName(), @@ -141,7 +141,7 @@ // maximum allowed length, but not longer. // Test with a short ID. - $id_length_config_test = \Drupal::entityTypeManager()->getStorage('config_test')->create([ + $id_length_config_test = $storage->create([ 'id' => $this->randomMachineName(8), ]); try { @@ -155,7 +155,7 @@ } // Test with an ID of the maximum allowed length. - $id_length_config_test = \Drupal::entityTypeManager()->getStorage('config_test')->create([ + $id_length_config_test = $storage->create([ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH), ]); try { @@ -169,7 +169,7 @@ } // Test with an ID exceeding the maximum allowed length. - $id_length_config_test = \Drupal::entityTypeManager()->getStorage('config_test')->create([ + $id_length_config_test = $storage->create([ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH + 1), ]); try { @@ -188,7 +188,7 @@ // Ensure that creating an entity with the same id as an existing one is not // possible. - $same_id = \Drupal::entityTypeManager()->getStorage('config_test')->create([ + $same_id = $storage->create([ 'id' => $config_test->id(), ]); $this->assertIdentical($same_id->isNew(), TRUE); @@ -223,7 +223,7 @@ // Test config entity prepopulation. \Drupal::state()->set('config_test.prepopulate', TRUE); - $config_test = \Drupal::entityTypeManager()->getStorage('config_test')->create(['foo' => 'bar']); + $config_test = $storage->create(['foo' => 'bar']); $this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated'); } diff -u b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php --- b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php @@ -599,7 +599,8 @@ $key_value = $this->container->get('keyvalue')->get(QueryFactory::CONFIG_LOOKUP_PREFIX . 'config_test'); $test_entities = []; - $entity = \Drupal::entityTypeManager()->getStorage('config_test')->create([ + $storage = \Drupal::entityTypeManager()->getStorage('config_test'); + $entity = $storage->create([ 'label' => $this->randomMachineName(), 'id' => '1', 'style' => 'test', @@ -612,7 +613,7 @@ $expected[] = $entity->getConfigDependencyName(); $this->assertEqual($expected, $key_value->get('style:test')); - $entity = \Drupal::entityTypeManager()->getStorage('config_test')->create([ + $entity = $storage->create([ 'label' => $this->randomMachineName(), 'id' => '2', 'style' => 'test', @@ -623,7 +624,7 @@ $expected[] = $entity->getConfigDependencyName(); $this->assertEqual($expected, $key_value->get('style:test')); - $entity = \Drupal::entityTypeManager()->getStorage('config_test')->create([ + $entity = $storage->create([ 'label' => $this->randomMachineName(), 'id' => '3', 'style' => 'blah',