diff --git a/core/modules/config/src/Tests/ConfigDiffTest.php b/core/modules/config/src/Tests/ConfigDiffTest.php index 1f32b27..caa8cad 100644 --- a/core/modules/config/src/Tests/ConfigDiffTest.php +++ b/core/modules/config/src/Tests/ConfigDiffTest.php @@ -7,6 +7,7 @@ namespace Drupal\config\Tests; +use Drupal\config_test\Entity\ConfigTest; use Drupal\simpletest\KernelTestBase; /** @@ -81,10 +82,10 @@ function testDiff() { // Test diffing a renamed config entity. $test_entity_id = $this->randomMachineName(); - $test_entity = entity_create('config_test', array( + $test_entity = ConfigTest::create([ 'id' => $test_entity_id, 'label' => $this->randomMachineName(), - )); + ]); $test_entity->save(); $data = $active->read('config_test.dynamic.' . $test_entity_id); $sync->write('config_test.dynamic.' . $test_entity_id, $data); diff --git a/core/modules/config/src/Tests/ConfigEntityNormalizeTest.php b/core/modules/config/src/Tests/ConfigEntityNormalizeTest.php index 7e0acef..7bc012d 100644 --- a/core/modules/config/src/Tests/ConfigEntityNormalizeTest.php +++ b/core/modules/config/src/Tests/ConfigEntityNormalizeTest.php @@ -7,6 +7,7 @@ namespace Drupal\config\Tests; +use Drupal\config_test\Entity\ConfigTest; use Drupal\simpletest\KernelTestBase; /** @@ -29,7 +30,7 @@ protected function setUp() { } public function testNormalize() { - $config_entity = entity_create('config_test', array('id' => 'system', 'label' => 'foobar', 'weight' => 1)); + $config_entity = ConfigTest::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/modules/config/src/Tests/ConfigEntityStatusTest.php b/core/modules/config/src/Tests/ConfigEntityStatusTest.php index caad767..3b8e7da 100644 --- a/core/modules/config/src/Tests/ConfigEntityStatusTest.php +++ b/core/modules/config/src/Tests/ConfigEntityStatusTest.php @@ -7,6 +7,7 @@ namespace Drupal\config\Tests; +use Drupal\config_test\Entity\ConfigTest; use Drupal\simpletest\KernelTestBase; /** @@ -27,9 +28,9 @@ class ConfigEntityStatusTest extends KernelTestBase { * Tests the enabling/disabling of entities. */ function testCRUD() { - $entity = entity_create('config_test', array( + $entity = ConfigTest::create([ 'id' => strtolower($this->randomMachineName()), - )); + ]); $this->assertTrue($entity->status(), 'Default status is enabled.'); $entity->save(); $this->assertTrue($entity->status(), 'Status is enabled after saving.'); diff --git a/core/modules/config/src/Tests/ConfigEntityTest.php b/core/modules/config/src/Tests/ConfigEntityTest.php index 13ab721..8f07a7a 100644 --- a/core/modules/config/src/Tests/ConfigEntityTest.php +++ b/core/modules/config/src/Tests/ConfigEntityTest.php @@ -8,6 +8,7 @@ namespace Drupal\config\Tests; use Drupal\Component\Utility\SafeMarkup; +use Drupal\config_test\Entity\ConfigTest; use Drupal\Core\Entity\EntityMalformedException; use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Config\Entity\ConfigEntityStorage; @@ -40,7 +41,7 @@ class ConfigEntityTest extends WebTestBase { function testCRUD() { $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId(); // Verify default properties on a newly created empty entity. - $empty = entity_create('config_test'); + $empty = ConfigTest::create(); $this->assertTrue($empty->uuid()); $this->assertIdentical($empty->label, NULL); $this->assertIdentical($empty->style, NULL); @@ -81,9 +82,9 @@ function testCRUD() { } // Verify that an entity with an empty ID string is considered empty, too. - $empty_id = entity_create('config_test', array( + $empty_id = ConfigTest::create([ 'id' => '', - )); + ]); $this->assertIdentical($empty_id->isNew(), TRUE); try { $empty_id->save(); @@ -94,11 +95,11 @@ function testCRUD() { } // Verify properties on a newly created entity. - $config_test = entity_create('config_test', $expected = array( + $config_test = ConfigTest::create($expected = [ 'id' => $this->randomMachineName(), 'label' => $this->randomString(), 'style' => $this->randomMachineName(), - )); + ]); $this->assertTrue($config_test->uuid()); $this->assertNotEqual($config_test->uuid(), $empty->uuid()); $this->assertIdentical($config_test->label, $expected['label']); @@ -146,9 +147,9 @@ function testCRUD() { // maximum allowed length, but not longer. // Test with a short ID. - $id_length_config_test = entity_create('config_test', array( + $id_length_config_test = ConfigTest::create([ 'id' => $this->randomMachineName(8), - )); + ]); try { $id_length_config_test->save(); $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", array( @@ -160,9 +161,9 @@ function testCRUD() { } // Test with an ID of the maximum allowed length. - $id_length_config_test = entity_create('config_test', array( + $id_length_config_test = ConfigTest::create([ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH), - )); + ]); try { $id_length_config_test->save(); $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", array( @@ -174,9 +175,9 @@ function testCRUD() { } // Test with an ID exceeding the maximum allowed length. - $id_length_config_test = entity_create('config_test', array( + $id_length_config_test = ConfigTest::create([ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH + 1), - )); + ]); try { $status = $id_length_config_test->save(); $this->fail(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", array( @@ -193,9 +194,9 @@ function testCRUD() { // Ensure that creating an entity with the same id as an existing one is not // possible. - $same_id = entity_create('config_test', array( + $same_id = ConfigTest::create([ 'id' => $config_test->id(), - )); + ]); $this->assertIdentical($same_id->isNew(), TRUE); try { $same_id->save(); @@ -227,7 +228,7 @@ function testCRUD() { // Test config entity prepopulation. \Drupal::state()->set('config_test.prepopulate', TRUE); - $config_test = entity_create('config_test', array('foo' => 'bar')); + $config_test = ConfigTest::create(['foo' => 'bar']); $this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated'); } diff --git a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php index fe4df02..91133d4 100644 --- a/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php +++ b/core/modules/config/src/Tests/ConfigImportRenameValidationTest.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; use Drupal\Component\Uuid\Php; +use Drupal\config_test\Entity\ConfigTest; use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\ConfigImporterException; use Drupal\Core\Config\StorageComparer; @@ -72,10 +73,10 @@ protected function setUp() { public function testRenameValidation() { // Create a test entity. $test_entity_id = $this->randomMachineName(); - $test_entity = entity_create('config_test', array( + $test_entity = ConfigTest::create([ 'id' => $test_entity_id, 'label' => $this->randomMachineName(), - )); + ]); $test_entity->save(); $uuid = $test_entity->uuid(); diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php index 13b56d5..fa7f88b 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php @@ -8,6 +8,7 @@ namespace Drupal\config_translation\Tests; use Drupal\Component\Utility\Html; +use Drupal\config_test\Entity\ConfigTest; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\simpletest\WebTestBase; @@ -95,10 +96,10 @@ public function testMapperListPage() { ); foreach ($labels as $label) { - $test_entity = entity_create('config_test', array( + $test_entity = ConfigTest::create([ 'id' => $this->randomMachineName(), 'label' => $label, - )); + ]); $test_entity->save(); $base_url = 'admin/structure/config_test/manage/' . $test_entity->id(); diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php index ef536f4..f633fef 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\SafeMarkup; use Drupal\config\Tests\AssertConfigEntityImportTrait; +use Drupal\config_test\Entity\ConfigTest; use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\simpletest\WebTestBase; @@ -198,9 +199,9 @@ protected function assertFieldValues($entity_name, $referenced_entities) { * An array of entity objects. */ protected function getTestEntities() { - $config_entity_1 = entity_create('config_test', array('id' => $this->randomMachineName(), 'label' => $this->randomMachineName())); + $config_entity_1 = ConfigTest::create(['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]); $config_entity_1->save(); - $config_entity_2 = entity_create('config_test', array('id' => $this->randomMachineName(), 'label' => $this->randomMachineName())); + $config_entity_2 = ConfigTest::create(['id' => $this->randomMachineName(), 'label' => $this->randomMachineName()]); $config_entity_2->save(); $content_entity_1 = EntityTest::create(array('name' => $this->randomMachineName())); diff --git a/core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php b/core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php index 09a21d2..b854bd8 100644 --- a/core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php +++ b/core/modules/system/src/Tests/Entity/ConfigEntityQueryTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Entity; +use Drupal\config_test\Entity\ConfigTest; use Drupal\Core\Config\Entity\Query\QueryFactory; use Drupal\simpletest\KernelTestBase; use Drupal\config_test\Entity\ConfigQueryTest; @@ -604,11 +605,11 @@ public function testLookupKeys() { $key_value = $this->container->get('keyvalue')->get(QueryFactory::CONFIG_LOOKUP_PREFIX . 'config_test'); $test_entities = []; - $entity = entity_create('config_test', array( + $entity = ConfigTest::create([ 'label' => $this->randomMachineName(), 'id' => '1', 'style' => 'test', - )); + ]); $test_entities[$entity->getConfigDependencyName()] = $entity; $entity->enforceIsNew(); $entity->save(); @@ -617,22 +618,22 @@ public function testLookupKeys() { $expected[] = $entity->getConfigDependencyName(); $this->assertEqual($expected, $key_value->get('style:test')); - $entity = entity_create('config_test', array( + $entity = ConfigTest::create([ 'label' => $this->randomMachineName(), 'id' => '2', 'style' => 'test', - )); + ]); $test_entities[$entity->getConfigDependencyName()] = $entity; $entity->enforceIsNew(); $entity->save(); $expected[] = $entity->getConfigDependencyName(); $this->assertEqual($expected, $key_value->get('style:test')); - $entity = entity_create('config_test', array( + $entity = ConfigTest::create([ 'label' => $this->randomMachineName(), 'id' => '3', 'style' => 'blah', - )); + ]); $entity->enforceIsNew(); $entity->save(); // Do not add this entity to the list of expected result as it has a