summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2017-12-02 11:15:26 (GMT)
committerxjm2017-12-02 11:20:29 (GMT)
commit718586000648fde927b45ad7bfc26a4d3128219a (patch)
treef2615512105196b51247d49cfaa814054e5ccb23
parentdbfe03c000f60596cd3e8812116fcf09da7e41ea (diff)
Issue #2641518 by dimaro, Mac_Weber, pk188, Mile23, anya_m, naveenvalecha, heykarthikwithu, aditya_anurag, nesta_, anchal29, rakesh.gectcr, sdstyles: Replace deprecated usage of entity_create('config_test') with a direct call to ConfigTest::create()
-rw-r--r--core/modules/config/tests/src/Functional/ConfigEntityTest.php17
-rw-r--r--core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php3
-rw-r--r--core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php5
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php2
-rw-r--r--core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php7
8 files changed, 22 insertions, 18 deletions
diff --git a/core/modules/config/tests/src/Functional/ConfigEntityTest.php b/core/modules/config/tests/src/Functional/ConfigEntityTest.php
index 5b237c4..4eb0744 100644
--- 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 @@ class ConfigEntityTest extends BrowserTestBase {
}
// 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 @@ class ConfigEntityTest extends BrowserTestBase {
}
// 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 @@ class ConfigEntityTest extends BrowserTestBase {
// 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 @@ class ConfigEntityTest extends BrowserTestBase {
}
// 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 @@ class ConfigEntityTest extends BrowserTestBase {
}
// 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 @@ class ConfigEntityTest extends BrowserTestBase {
// 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 @@ class ConfigEntityTest extends BrowserTestBase {
// 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');
}
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
index 55b02dc..dff6270 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
@@ -87,8 +87,9 @@ class ConfigTranslationOverviewTest extends BrowserTestBase {
$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,
]);
diff --git a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php
index ea65c4b..940ad37 100644
--- a/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php
+++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceIntegrationTest.php
@@ -197,9 +197,10 @@ class EntityReferenceIntegrationTest extends BrowserTestBase {
* An array of entity objects.
*/
protected function getTestEntities() {
- $config_entity_1 = entity_create('config_test', ['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 = entity_create('config_test', ['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 --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php
index b69735e..f29b88a 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigDiffTest.php
@@ -75,7 +75,7 @@ class ConfigDiffTest extends KernelTestBase {
// Test diffing a renamed config entity.
$test_entity_id = $this->randomMachineName();
- $test_entity = entity_create('config_test', [
+ $test_entity = \Drupal::entityTypeManager()->getStorage('config_test')->create([
'id' => $test_entity_id,
'label' => $this->randomMachineName(),
]);
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php
index 5a137b9..4cbc16a 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityNormalizeTest.php
@@ -24,7 +24,7 @@ class ConfigEntityNormalizeTest extends KernelTestBase {
}
public function testNormalize() {
- $config_entity = entity_create('config_test', ['id' => 'system', 'label' => 'foobar', 'weight' => 1]);
+ $config_entity = \Drupal::entityTypeManager()->getStorage('config_test')->create(['id' => 'system', 'label' => 'foobar', 'weight' => 1]);
$config_entity->save();
// Modify stored config entity, this is comparable with a schema change.
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php
index 021136d..20ceef4 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStatusTest.php
@@ -22,7 +22,7 @@ class ConfigEntityStatusTest extends KernelTestBase {
* Tests the enabling/disabling of entities.
*/
public function testCRUD() {
- $entity = entity_create('config_test', [
+ $entity = \Drupal::entityTypeManager()->getStorage('config_test')->create([
'id' => strtolower($this->randomMachineName()),
]);
$this->assertTrue($entity->status(), 'Default status is enabled.');
diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php
index cbb2e95..9c1875c 100644
--- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php
@@ -67,7 +67,7 @@ class ConfigImportRenameValidationTest extends KernelTestBase {
public function testRenameValidation() {
// Create a test entity.
$test_entity_id = $this->randomMachineName();
- $test_entity = entity_create('config_test', [
+ $test_entity = \Drupal::entityTypeManager()->getStorage('config_test')->create([
'id' => $test_entity_id,
'label' => $this->randomMachineName(),
]);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
index 78c7a5d..8dc101a 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php
@@ -626,7 +626,8 @@ class ConfigEntityQueryTest extends KernelTestBase {
$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',
@@ -638,7 +639,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
$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',
@@ -649,7 +650,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
$expected[] = $entity->getConfigDependencyName();
$this->assertEqual($expected, $key_value->get('style:test'));
- $entity = entity_create('config_test', [
+ $entity = $storage->create([
'label' => $this->randomMachineName(),
'id' => '3',
'style' => 'blah',