reverted: --- b/core/modules/config_translation/src/Tests/ConfigEntityTest.php +++ a/core/modules/config_translation/src/Tests/ConfigEntityTest.php @@ -35,8 +35,7 @@ public function testCRUD() { $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); // Verify default properties on a newly created empty entity. + $empty = entity_create('config_test'); - $storage = \Drupal::entityTypeManager()->getStorage('config_test'); - $empty = $storage->create(); $this->assertTrue($empty->uuid()); $this->assertIdentical($empty->label, NULL); $this->assertIdentical($empty->style, NULL); @@ -77,7 +76,7 @@ } // Verify that an entity with an empty ID string is considered empty, too. + $empty_id = entity_create('config_test', [ - $empty_id = $storage->create([ 'id' => '', ]); $this->assertIdentical($empty_id->isNew(), TRUE); @@ -90,7 +89,7 @@ } // Verify properties on a newly created entity. + $config_test = entity_create('config_test', $expected = [ - $config_test = $storage->create($expected = [ 'id' => $this->randomMachineName(), 'label' => $this->randomString(), 'style' => $this->randomMachineName(), @@ -142,7 +141,7 @@ // maximum allowed length, but not longer. // Test with a short ID. + $id_length_config_test = entity_create('config_test', [ - $id_length_config_test = $storage->create([ 'id' => $this->randomMachineName(8), ]); try { @@ -156,7 +155,7 @@ } // Test with an ID of the maximum allowed length. + $id_length_config_test = entity_create('config_test', [ - $id_length_config_test = $storage->create([ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH), ]); try { @@ -170,7 +169,7 @@ } // Test with an ID exceeding the maximum allowed length. + $id_length_config_test = entity_create('config_test', [ - $id_length_config_test = $storage->create([ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH + 1), ]); try { @@ -189,7 +188,7 @@ // Ensure that creating an entity with the same id as an existing one is not // possible. + $same_id = entity_create('config_test', [ - $same_id = $storage->create([ 'id' => $config_test->id(), ]); $this->assertIdentical($same_id->isNew(), TRUE); @@ -224,7 +223,7 @@ // Test config entity prepopulation. \Drupal::state()->set('config_test.prepopulate', TRUE); + $config_test = entity_create('config_test', ['foo' => 'bar']); - $config_test = $storage->create(['foo' => 'bar']); $this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated'); } reverted: --- b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php +++ a/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php @@ -90,7 +90,7 @@ ]; foreach ($labels as $label) { + $test_entity = entity_create('config_test', [ - $test_entity = \Drupal::entityTypeManager()->getStorage('config_test')->create([ 'id' => $this->randomMachineName(), 'label' => $label, ]); diff -u b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php --- b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php @@ -197,9 +197,10 @@ * An array of entity objects. */ protected function getTestEntities() { - $config_entity_1 = \Drupal::entityTypeManager()->getStorage('config_test')->create(['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]); + $storage = \Drupal::entityTypeManager()->getStorage('config_test'); + $config_entity_1 = $storage->create(['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]); $config_entity_1->save(); - $config_entity_2 = \Drupal::entityTypeManager()->getStorage('config_test')->create(['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]); + $config_entity_2 = $storage->create(['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]); $config_entity_2->save(); $content_entity_1 = EntityTest::create(['name' => $this->randomMachineName()]); 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,8 +599,7 @@ $key_value = $this->container->get('keyvalue')->get(QueryFactory::CONFIG_LOOKUP_PREFIX . 'config_test'); $test_entities = []; - $storage = \Drupal::entityTypeManager()->getStorage('config_test'); - $entity = $storage->create([ + $entity = entity_create('config_test', [ 'label' => $this->randomMachineName(), 'id' => '1', 'style' => 'test', @@ -613,7 +612,7 @@ $expected[] = $entity->getConfigDependencyName(); $this->assertEqual($expected, $key_value->get('style:test')); - $entity = $storage->create([ + $entity = entity_create('config_test', [ 'label' => $this->randomMachineName(), 'id' => '2', 'style' => 'test', @@ -627,7 +626,8 @@ $key_value = $this->container->get('keyvalue')->get(QueryFactory::CONFIG_LOOKUP_PREFIX . 'config_test'); $test_entities = []; - $entity = entity_create('config_test', [ + $storage = \Drupal::entityTypeManager()->getStorage('config_test'); + $entity = $storage->create([ 'label' => $this->randomMachineName(), 'id' => '1', 'style' => 'test', @@ -639,7 +639,7 @@ $expected[] = $entity->getConfigDependencyName(); $this->assertEqual($expected, $key_value->get('style:test')); - $entity = entity_create('config_test', [ + $entity = $storage->create([ 'label' => $this->randomMachineName(), 'id' => '2', 'style' => 'test', only in patch2: unchanged: --- a/core/modules/config/tests/src/Functional/ConfigEntityTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityTest.php @@ -35,7 +35,8 @@ class ConfigEntityTest extends BrowserTestBase { public function testCRUD() { $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); // Verify default properties on a newly created empty entity. - $empty = entity_create('config_test'); + $storage = \Drupal::entityTypeManager()->getStorage('config_test'); + $empty = $storage->create(); $this->assertTrue($empty->uuid()); $this->assertIdentical($empty->label, NULL); $this->assertIdentical($empty->style, NULL); @@ -76,7 +77,7 @@ public function testCRUD() { } // Verify that an entity with an empty ID string is considered empty, too. - $empty_id = entity_create('config_test', [ + $empty_id = $storage->create([ 'id' => '', ]); $this->assertIdentical($empty_id->isNew(), TRUE); @@ -89,7 +90,7 @@ public function testCRUD() { } // Verify properties on a newly created entity. - $config_test = entity_create('config_test', $expected = [ + $config_test = $storage->create($expected = [ 'id' => $this->randomMachineName(), 'label' => $this->randomString(), 'style' => $this->randomMachineName(), @@ -141,7 +142,7 @@ public function testCRUD() { // maximum allowed length, but not longer. // Test with a short ID. - $id_length_config_test = entity_create('config_test', [ + $id_length_config_test = $storage->create([ 'id' => $this->randomMachineName(8), ]); try { @@ -155,7 +156,7 @@ public function testCRUD() { } // Test with an ID of the maximum allowed length. - $id_length_config_test = entity_create('config_test', [ + $id_length_config_test = $storage->create([ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH), ]); try { @@ -169,7 +170,7 @@ public function testCRUD() { } // Test with an ID exceeding the maximum allowed length. - $id_length_config_test = entity_create('config_test', [ + $id_length_config_test = $storage->create([ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH + 1), ]); try { @@ -188,7 +189,7 @@ public function testCRUD() { // Ensure that creating an entity with the same id as an existing one is not // possible. - $same_id = entity_create('config_test', [ + $same_id = $storage->create([ 'id' => $config_test->id(), ]); $this->assertIdentical($same_id->isNew(), TRUE); @@ -223,7 +224,7 @@ public function testCRUD() { // Test config entity prepopulation. \Drupal::state()->set('config_test.prepopulate', TRUE); - $config_test = entity_create('config_test', ['foo' => 'bar']); + $config_test = $storage->create(['foo' => 'bar']); $this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated'); } only in patch2: unchanged: --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php @@ -87,8 +87,9 @@ public function testMapperListPage() { $this->randomString(), ]; + $storage = \Drupal::entityTypeManager()->getStorage('config_test'); foreach ($labels as $label) { - $test_entity = entity_create('config_test', [ + $test_entity = $storage->create([ 'id' => $this->randomMachineName(), 'label' => $label, ]);