diff --git a/core/modules/comment/src/Tests/CommentCacheTagsTest.php b/core/modules/comment/src/Tests/CommentCacheTagsTest.php index 597e7ac31a9323976ab54ce11377f3bfc29c5d55..b7f6f922bc810ece0815e1c506515ede4edb10ca 100644 --- a/core/modules/comment/src/Tests/CommentCacheTagsTest.php +++ b/core/modules/comment/src/Tests/CommentCacheTagsTest.php @@ -11,6 +11,7 @@ use Drupal\comment\CommentManagerInterface; use Drupal\comment\Entity\Comment; use Drupal\Core\Entity\EntityInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase; use Drupal\user\Entity\Role; @@ -70,7 +71,7 @@ protected function createEntity() { $field->save(); // Create a "Camelids" test entity that the comment will be assigned to. - $this->entityTestCamelid = entity_create('entity_test', array( + $this->entityTestCamelid = EntityTest::create(array( 'name' => 'Camelids', 'type' => 'bar', )); @@ -101,7 +102,7 @@ public function testCommentEntity() { $this->verifyPageCache($this->entityTestCamelid->urlInfo(), 'HIT'); // Create a "Hippopotamus" comment. - $this->entityTestHippopotamidae = entity_create('entity_test', array( + $this->entityTestHippopotamidae = EntityTest::create(array( 'name' => 'Hippopotamus', 'type' => 'bar', )); diff --git a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php index 41c346457843e9767a23a6d2294c72cc142841c9..3b9cb9767a8858f93fb9ef04cfbe1066a4d6d898 100644 --- a/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php +++ b/core/modules/comment/src/Tests/CommentDefaultFormatterCacheTagsTest.php @@ -14,6 +14,7 @@ use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Session\Session; use Drupal\comment\Entity\Comment; +use Drupal\entity_test\Entity\EntityTest; /** * Tests the bubbling up of comment cache tags when using the Comment list @@ -74,7 +75,7 @@ public function testCacheTags() { $renderer = $this->container->get('renderer'); // Create the entity that will be commented upon. - $commented_entity = entity_create('entity_test', array('name' => $this->randomMachineName())); + $commented_entity = EntityTest::create(array('name' => $this->randomMachineName())); $commented_entity->save(); // Verify cache tags on the rendered entity before it has comments. diff --git a/core/modules/comment/src/Tests/CommentItemTest.php b/core/modules/comment/src/Tests/CommentItemTest.php index e81c6fbab49c977dcbc4d54daa9c70e9d896b07c..9b28a58a8ed5b1a542e1e59ec319127e34705c06 100644 --- a/core/modules/comment/src/Tests/CommentItemTest.php +++ b/core/modules/comment/src/Tests/CommentItemTest.php @@ -9,6 +9,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Tests\FieldUnitTestBase; /** @@ -40,7 +41,7 @@ public function testCommentItem() { $this->addDefaultCommentField('entity_test', 'entity_test', 'comment'); // Verify entity creation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->name->value = $this->randomMachineName(); $entity->save(); @@ -52,7 +53,7 @@ public function testCommentItem() { // Test sample item generation. /** @var \Drupal\entity_test\Entity\EntityTest $entity */ - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->comment->generateSampleItems(); $this->entityValidateAndSave($entity); $this->assertTrue(in_array($entity->get('comment')->status, [ diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php index c217fdc6ad3a7826f3cb502bfa1277e7aad0c6bc..54c663027f350a621f6c8669af06521d6588dd84 100644 --- a/core/modules/comment/src/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php @@ -11,6 +11,7 @@ use Drupal\comment\Entity\Comment; use Drupal\comment\Entity\CommentType; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\field_ui\Tests\FieldUiTestTrait; @@ -92,7 +93,7 @@ protected function setUp() { // Create a test entity. $random_label = $this->randomMachineName(); $data = array('type' => 'entity_test', 'name' => $random_label); - $this->entity = entity_create('entity_test', $data); + $this->entity = EntityTest::create($data); $this->entity->save(); } @@ -433,7 +434,7 @@ function testCommentFunctionality() { // Test the new entity commenting inherits default. $random_label = $this->randomMachineName(); $data = array('bundle' => 'entity_test', 'name' => $random_label); - $new_entity = entity_create('entity_test', $data); + $new_entity = EntityTest::create($data); $new_entity->save(); $this->drupalGet('entity_test/manage/' . $new_entity->id() . '/edit'); $this->assertNoFieldChecked('edit-field-foobar-0-status-1'); diff --git a/core/modules/config/src/Tests/ConfigDependencyTest.php b/core/modules/config/src/Tests/ConfigDependencyTest.php index 050797dae91f158e2283b4427fbc9eeaea95e26c..c27f07d49c703c917a4381ef2385feaa860a9c0e 100644 --- a/core/modules/config/src/Tests/ConfigDependencyTest.php +++ b/core/modules/config/src/Tests/ConfigDependencyTest.php @@ -115,7 +115,7 @@ public function testDependencyManagement() { $this->assertTrue(isset($dependents['config_test.dynamic.entity4']), 'config_test.dynamic.entity4 has a dependency on the Node module.'); // Test dependency on a content entity. - $entity_test = entity_create('entity_test', array( + $entity_test = EntityTest::create(array( 'name' => $this->randomString(), 'type' => 'entity_test', )); diff --git a/core/modules/config/src/Tests/ConfigImporterMissingContentTest.php b/core/modules/config/src/Tests/ConfigImporterMissingContentTest.php index cb5522db72cb47e5c459f2a97d94f1a6062678f7..e39412378e69585bdbf7bcc759f3feff7818c6fb 100644 --- a/core/modules/config/src/Tests/ConfigImporterMissingContentTest.php +++ b/core/modules/config/src/Tests/ConfigImporterMissingContentTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\StorageComparer; +use Drupal\entity_test\Entity\EntityTest; use Drupal\simpletest\KernelTestBase; /** @@ -77,9 +78,9 @@ function testMissingContent() { // on two content entities that do not exist. $storage = $this->container->get('config.storage'); $sync = $this->container->get('config.storage.sync'); - $entity_one = entity_create('entity_test', array('name' => 'one')); - $entity_two = entity_create('entity_test', array('name' => 'two')); - $entity_three = entity_create('entity_test', array('name' => 'three')); + $entity_one = EntityTest::create(array('name' => 'one')); + $entity_two = EntityTest::create(array('name' => 'two')); + $entity_three = EntityTest::create(array('name' => 'three')); $dynamic_name = 'config_test.dynamic.dotted.default'; $original_dynamic_data = $storage->read($dynamic_name); // Entity one will be resolved by diff --git a/core/modules/datetime/src/Tests/DateTimeItemTest.php b/core/modules/datetime/src/Tests/DateTimeItemTest.php index 2f4fbcc37f4a91a721cecddf4f8c2e0ba7d07393..03d72e9296100ac8c324495e9d61b5a3421ffc39 100644 --- a/core/modules/datetime/src/Tests/DateTimeItemTest.php +++ b/core/modules/datetime/src/Tests/DateTimeItemTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Entity\FieldStorageConfig; @@ -53,7 +54,7 @@ protected function setUp() { */ public function testDateTimeItem() { // Verify entity creation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = '2014-01-01T20:00:00Z'; $entity->field_datetime = $value; $entity->name->value = $this->randomMachineName(); @@ -78,7 +79,7 @@ public function testDateTimeItem() { $this->assertEqual($entity->field_datetime->value, $new_value); // Test the generateSampleValue() method. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_datetime->generateSampleItems(); $this->entityValidateAndSave($entity); } @@ -88,7 +89,7 @@ public function testDateTimeItem() { */ public function testSetValue() { // Test DateTimeItem::setValue() using string. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = '2014-01-01T20:00:00Z'; $entity->get('field_datetime')->set(0, $value); $entity->save(); @@ -98,7 +99,7 @@ public function testSetValue() { $this->assertEqual($entity->field_datetime[0]->value, $value, 'DateTimeItem::setValue() works with string value.'); // Test DateTimeItem::setValue() using property array. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = '2014-01-01T20:00:00Z'; $entity->set('field_datetime', $value); $entity->save(); @@ -113,7 +114,7 @@ public function testSetValue() { */ public function testSetValueProperty() { // Test Date::setValue(). - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = '2014-01-01T20:00:00Z'; $entity->set('field_datetime', $value); diff --git a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php index 8f792c0c33537726fa5a6d6c635d11c8046970c9..1b4798b5ceb9e9b78b71e2eaf6c8357848a61edf 100644 --- a/core/modules/editor/src/Tests/QuickEditIntegrationTest.php +++ b/core/modules/editor/src/Tests/QuickEditIntegrationTest.php @@ -11,6 +11,7 @@ use Drupal\Core\EventSubscriber\AjaxResponseSubscriber; use Drupal\Core\Language\LanguageInterface; use Drupal\editor\Entity\Editor; +use Drupal\entity_test\Entity\EntityTest; use Drupal\quickedit\MetadataGenerator; use Drupal\quickedit\Tests\QuickEditTestBase; use Drupal\quickedit_test\MockEditEntityFieldAccessCheck; @@ -143,7 +144,7 @@ public function testEditorSelection() { $this->editorSelector = $this->container->get('quickedit.editor.selector'); // Create an entity with values for this text field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$this->fieldName}->value = 'Hello, world!'; $entity->{$this->fieldName}->format = 'filtered_html'; $entity->save(); @@ -172,7 +173,7 @@ public function testMetadata() { $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); // Create an entity with values for the field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$this->fieldName}->value = 'Test'; $entity->{$this->fieldName}->format = 'full_html'; $entity->save(); @@ -209,7 +210,7 @@ public function testAttachments() { */ public function testGetUntransformedTextCommand() { // Create an entity with values for the field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$this->fieldName}->value = 'Test'; $entity->{$this->fieldName}->format = 'full_html'; $entity->save(); diff --git a/core/modules/field/src/Tests/Boolean/BooleanItemTest.php b/core/modules/field/src/Tests/Boolean/BooleanItemTest.php index 8b8c192c5ef89ad717af50739e5bd40e87d38ab1..8ae2259d4cff8b4c11f250ba857c99a84b287cb7 100644 --- a/core/modules/field/src/Tests/Boolean/BooleanItemTest.php +++ b/core/modules/field/src/Tests/Boolean/BooleanItemTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Entity\FieldStorageConfig; @@ -51,7 +52,7 @@ protected function setUp() { */ public function testBooleanItem() { // Verify entity creation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = '1'; $entity->field_boolean = $value; $entity->name->value = $this->randomMachineName(); @@ -76,7 +77,7 @@ public function testBooleanItem() { $this->assertEqual($entity->field_boolean->value, $new_value); // Test sample item generation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_boolean->generateSampleItems(); $this->entityValidateAndSave($entity); } diff --git a/core/modules/field/src/Tests/DisplayApiTest.php b/core/modules/field/src/Tests/DisplayApiTest.php index 1526a4f2548cd347082177e2ac12df611b013da4..362699b12dfd4080fb62760d506a33de38513578 100644 --- a/core/modules/field/src/Tests/DisplayApiTest.php +++ b/core/modules/field/src/Tests/DisplayApiTest.php @@ -8,6 +8,7 @@ namespace Drupal\field\Tests; use Drupal\Core\Entity\Entity\EntityViewMode; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -110,7 +111,7 @@ protected function setUp() { // Create an entity with values. $this->values = $this->_generateTestFieldValues($this->cardinality); - $this->entity = entity_create('entity_test'); + $this->entity = EntityTest::create(); $this->entity->{$this->fieldName}->setValue($this->values); $this->entity->save(); } diff --git a/core/modules/field/src/Tests/Email/EmailItemTest.php b/core/modules/field/src/Tests/Email/EmailItemTest.php index 3267ce4bbd78e87176852d12284f942ce0d1b84d..4427e3f5208fd45ecfab71a4493cd314cb903ce9 100644 --- a/core/modules/field/src/Tests/Email/EmailItemTest.php +++ b/core/modules/field/src/Tests/Email/EmailItemTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Entity\FieldStorageConfig; @@ -48,7 +49,7 @@ protected function setUp() { */ public function testEmailItem() { // Verify entity creation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = 'test@example.com'; $entity->field_email = $value; $entity->name->value = $this->randomMachineName(); @@ -73,7 +74,7 @@ public function testEmailItem() { $this->assertEqual($entity->field_email->value, $new_value); // Test sample item generation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_email->generateSampleItems(); $this->entityValidateAndSave($entity); } diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php index 4d678f8a50428a1531135af3e2bb5c35cf1a0e09..ef536f48bc8f86a4a3e22ed8cc741045bb19cfc3 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\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\simpletest\WebTestBase; @@ -202,9 +203,9 @@ protected function getTestEntities() { $config_entity_2 = entity_create('config_test', array('id' => $this->randomMachineName(), 'label' => $this->randomMachineName())); $config_entity_2->save(); - $content_entity_1 = entity_create('entity_test', array('name' => $this->randomMachineName())); + $content_entity_1 = EntityTest::create(array('name' => $this->randomMachineName())); $content_entity_1->save(); - $content_entity_2 = entity_create('entity_test', array('name' => $this->randomMachineName())); + $content_entity_2 = EntityTest::create(array('name' => $this->randomMachineName())); $content_entity_2->save(); return array( diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php index 02456388cc212b94bfd55667fbdec37d33800388..120995f2ff3ac29fd7b41bd9e65acd7cb73dd357 100644 --- a/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php +++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php @@ -115,7 +115,7 @@ public function testContentEntityReferenceItem() { $tid = $this->term->id(); // Just being able to create the entity like this verifies a lot of code. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_test_taxonomy_term->target_id = $tid; $entity->name->value = $this->randomMachineName(); $entity->save(); @@ -178,11 +178,11 @@ public function testContentEntityReferenceItem() { // Delete terms so we have nothing to reference and try again $term->delete(); $term2->delete(); - $entity = entity_create('entity_test', array('name' => $this->randomMachineName())); + $entity = EntityTest::create(array('name' => $this->randomMachineName())); $entity->save(); // Test the generateSampleValue() method. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_test_taxonomy_term->generateSampleItems(); $entity->field_test_taxonomy_vocabulary->generateSampleItems(); $this->entityValidateAndSave($entity); @@ -211,7 +211,7 @@ public function testConfigEntityReferenceItem() { $referenced_entity_id = $this->vocabulary->id(); // Just being able to create the entity like this verifies a lot of code. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_test_taxonomy_vocabulary->target_id = $referenced_entity_id; $entity->name->value = $this->randomMachineName(); $entity->save(); @@ -247,7 +247,7 @@ public function testConfigEntityReferenceItem() { // Delete terms so we have nothing to reference and try again $this->vocabulary->delete(); $vocabulary2->delete(); - $entity = entity_create('entity_test', array('name' => $this->randomMachineName())); + $entity = EntityTest::create(array('name' => $this->randomMachineName())); $entity->save(); } @@ -285,7 +285,7 @@ public function testEntitySaveOrder() { 'vid' => $this->term->bundle(), 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, )); - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); // Now assign the unsaved term to the field. $entity->field_test_taxonomy_term->entity = $term; $entity->name->value = $this->randomMachineName(); diff --git a/core/modules/field/src/Tests/FieldAttachOtherTest.php b/core/modules/field/src/Tests/FieldAttachOtherTest.php index e76145e41cebf1cf84c8e7327e812772978840cf..37c6fecc109ad8ff546441d3976778ec004de3ab 100644 --- a/core/modules/field/src/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/src/Tests/FieldAttachOtherTest.php @@ -8,6 +8,7 @@ namespace Drupal\field\Tests; use Drupal\Core\Form\FormState; +use Drupal\entity_test\Entity\EntityTest; /** * Tests other Field API functions. @@ -143,9 +144,9 @@ function testEntityDisplayViewMultiple() { )); // Create two entities. - $entity1 = entity_create('entity_test', array('id' => 1, 'type' => 'entity_test')); + $entity1 = EntityTest::create(array('id' => 1, 'type' => 'entity_test')); $entity1->{$this->fieldTestData->field_name}->setValue($this->_generateTestFieldValues(1)); - $entity2 = entity_create('entity_test', array('id' => 2, 'type' => 'entity_test')); + $entity2 = EntityTest::create(array('id' => 2, 'type' => 'entity_test')); $entity2->{$this->fieldTestData->field_name}->setValue($this->_generateTestFieldValues(1)); // Run buildMultiple(), and check that the entities come out as expected. @@ -164,7 +165,7 @@ function testEntityDisplayViewMultiple() { */ function testEntityCache() { // Initialize random values and a test entity. - $entity_init = entity_create('entity_test', array('type' => $this->fieldTestData->field->getTargetBundle())); + $entity_init = EntityTest::create(array('type' => $this->fieldTestData->field->getTargetBundle())); $values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality()); // Non-cacheable entity type. diff --git a/core/modules/field/src/Tests/FieldCrudTest.php b/core/modules/field/src/Tests/FieldCrudTest.php index 08daa6cecb139f3f0d2db1302281a991cd40fc05..72738add618d9a0d80a8ee10979cbd1aa5679587 100644 --- a/core/modules/field/src/Tests/FieldCrudTest.php +++ b/core/modules/field/src/Tests/FieldCrudTest.php @@ -291,7 +291,7 @@ function testDeleteFieldCrossDeletion() { * @see field_test_entity_bundle_field_info_alter() */ protected function doFieldValidationTests() { - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->set($this->fieldStorage->getName(), 1); $violations = $entity->validate(); $this->assertEqual(count($violations), 0, 'No violations found when in-range value passed.'); diff --git a/core/modules/field/src/Tests/FieldDataCountTest.php b/core/modules/field/src/Tests/FieldDataCountTest.php index 8b992b7ddefb852d6cce6e5060d4b85cd956ecb8..a844b056a30de7a261b6d64e162fc0eed5597244 100644 --- a/core/modules/field/src/Tests/FieldDataCountTest.php +++ b/core/modules/field/src/Tests/FieldDataCountTest.php @@ -8,6 +8,7 @@ namespace Drupal\field\Tests; use Drupal\Core\Entity\Sql\SqlContentEntityStorage; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -70,7 +71,7 @@ public function testEntityCountAndHasData() { $this->assertIdentical($this->storage->countFieldData($field_storage), 0, 'There are 0 entities with field data.'); // Create 1 entity without the field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->name->value = $this->randomMachineName(); $entity->save(); @@ -79,7 +80,7 @@ public function testEntityCountAndHasData() { // Create 12 entities to ensure that the purging works as expected. for ($i=0; $i < 12; $i++) { - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_int[] = mt_rand(1, 99); $entity->field_int[] = mt_rand(1, 99); $entity->name[] = $this->randomMachineName(); diff --git a/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php index f01db0b5bb38b74fc7fa174eeca2074e73087077..7cfed64fe23ed4855f0a9e70a25e2bc3a7620f5b 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php @@ -7,6 +7,7 @@ namespace Drupal\field\Tests; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -65,7 +66,7 @@ public function testImportDeleteUninstall() { 'bundle' => 'entity_test', ])->save(); - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = '+0123456789'; $entity->field_test = $value; $entity->field_int = '99'; @@ -130,7 +131,7 @@ public function testImportAlreadyDeletedUninstall() { // Create 12 entities to ensure that the purging works as expected. for ($i=0; $i < 12; $i++) { - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = '+0123456789'; $entity->field_test = $value; $entity->name->value = $this->randomMachineName(); diff --git a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php index e8a964e15547586c2649fcc2384b3d8b0cc85129..71fbf91b23cfd6645ac769ced2e31ba68126f86c 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php @@ -7,6 +7,7 @@ namespace Drupal\field\Tests; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -63,7 +64,7 @@ public function testImportDeleteUninstall() { ])->save(); // Create an entity which has values for the telephone and text field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = '+0123456789'; $entity->field_tel = $value; $entity->field_date = time(); diff --git a/core/modules/field/src/Tests/FieldStorageCrudTest.php b/core/modules/field/src/Tests/FieldStorageCrudTest.php index 43d0aa07943a3e5e70587b5ec7a60bdf1383dd91..2b1dceef705a2365717fb0b16c27207543df28e4 100644 --- a/core/modules/field/src/Tests/FieldStorageCrudTest.php +++ b/core/modules/field/src/Tests/FieldStorageCrudTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityStorageException; use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; use Drupal\Core\Field\FieldException; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -355,7 +356,7 @@ function testDelete() { $this->assertTrue(!empty($field) && !$field->isDeleted(), 'A new field for a previously used field name is created.'); // Save an entity with data for the field - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $values[0]['value'] = mt_rand(1, 127); $entity->{$field_storage->getName()}->value = $values[0]['value']; $entity = $this->entitySaveReload($entity); @@ -408,7 +409,7 @@ function testUpdate() { $field->save(); do { - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); // Fill in the entity with more values than $cardinality. for ($i = 0; $i < 20; $i++) { // We can not use $i here because 0 values are filtered out. diff --git a/core/modules/field/src/Tests/Number/NumberItemTest.php b/core/modules/field/src/Tests/Number/NumberItemTest.php index 3f65fe24de732fc7748bc3a271fdcb38991c7d8d..8e99d973753459cd348855be58b791bc47a60222 100644 --- a/core/modules/field/src/Tests/Number/NumberItemTest.php +++ b/core/modules/field/src/Tests/Number/NumberItemTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Entity\FieldStorageConfig; @@ -50,7 +51,7 @@ protected function setUp() { */ public function testNumberItem() { // Verify entity creation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $integer = rand(0, 10); $entity->field_integer = $integer; $float = 3.14; @@ -98,7 +99,7 @@ public function testNumberItem() { $this->assertEqual($entity->field_decimal->value, $new_decimal); /// Test sample item generation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_integer->generateSampleItems(); $entity->field_float->generateSampleItems(); $entity->field_decimal->generateSampleItems(); diff --git a/core/modules/field/src/Tests/ShapeItemTest.php b/core/modules/field/src/Tests/ShapeItemTest.php index 20bb4e01bf271c730421ee9d3a4150a1121c5fb9..0a000ad81a7c099ce37fb9154260599d500bd114 100644 --- a/core/modules/field/src/Tests/ShapeItemTest.php +++ b/core/modules/field/src/Tests/ShapeItemTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -54,7 +55,7 @@ protected function setUp() { */ public function testShapeItem() { // Verify entity creation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $shape = 'cube'; $color = 'blue'; $entity->{$this->fieldName}->shape = $shape; diff --git a/core/modules/field/src/Tests/TestItemTest.php b/core/modules/field/src/Tests/TestItemTest.php index b4bf7ca8fa0ceb09aec7804e09107b750e90e44c..08b0baea30b81076a96bc384ad8720c6b9c38609 100644 --- a/core/modules/field/src/Tests/TestItemTest.php +++ b/core/modules/field/src/Tests/TestItemTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemListInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -55,7 +56,7 @@ protected function setUp() { */ public function testTestItem() { // Verify entity creation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = rand(1, 10); $entity->field_test = $value; $entity->name->value = $this->randomMachineName(); diff --git a/core/modules/field/src/Tests/Uri/UriItemTest.php b/core/modules/field/src/Tests/Uri/UriItemTest.php index 9dc50a2c6e146b97167e6f55b00936208a0d69e2..ddef127b012039e339bb5b704f3759ad8e2f8a61 100644 --- a/core/modules/field/src/Tests/Uri/UriItemTest.php +++ b/core/modules/field/src/Tests/Uri/UriItemTest.php @@ -8,6 +8,7 @@ namespace Drupal\field\Tests\Uri; use Drupal\Component\Utility\Unicode; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Tests\FieldUnitTestBase; @@ -70,7 +71,7 @@ public function testUriField() { ->save(); // Test the generateSampleValue() method. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->$field_name->generateSampleItems(); $this->entityValidateAndSave($entity); } diff --git a/core/modules/file/src/Tests/FileItemTest.php b/core/modules/file/src/Tests/FileItemTest.php index e94f4ee2e82c7ac8d5426dbb1fc63fdc5fa14f29..2941f4cc2461f281e944f16f89758a00e2aaac4f 100644 --- a/core/modules/file/src/Tests/FileItemTest.php +++ b/core/modules/file/src/Tests/FileItemTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Entity\FieldStorageConfig; @@ -80,7 +81,7 @@ public function testFileItem() { $this->assertEqual($handler_id, 'default:file'); // Create a test entity with the - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->file_test->target_id = $this->file->id(); $entity->file_test->display = 1; $entity->file_test->description = $description = $this->randomMachineName(); @@ -115,7 +116,7 @@ public function testFileItem() { $entity->delete(); // Test the generateSampleValue() method. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->file_test->generateSampleItems(); $this->entityValidateAndSave($entity); // Verify that the sample file was stored in the correct directory. @@ -134,7 +135,7 @@ public function testFileItem() { 'type' => 'file_default', 'weight' => 1, ])->save(); - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->file_test = array('entity' => $file3); $uri = $file3->getFileUri(); $output = entity_view($entity, 'default'); diff --git a/core/modules/hal/src/Tests/NormalizeTest.php b/core/modules/hal/src/Tests/NormalizeTest.php index 0f24d73aa70acbc48be28bbb15c6e250036c9961..a94823123fed850bf6036ac9efe28c14a093540a 100644 --- a/core/modules/hal/src/Tests/NormalizeTest.php +++ b/core/modules/hal/src/Tests/NormalizeTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Url; +use Drupal\entity_test\Entity\EntityTest; /** * Tests that entities can be normalized in HAL. @@ -30,9 +31,9 @@ protected function setUp() { * Tests the normalize function. */ public function testNormalize() { - $target_entity_de = entity_create('entity_test', (array('langcode' => 'de', 'field_test_entity_reference' => NULL))); + $target_entity_de = EntityTest::create((array('langcode' => 'de', 'field_test_entity_reference' => NULL))); $target_entity_de->save(); - $target_entity_en = entity_create('entity_test', (array('langcode' => 'en', 'field_test_entity_reference' => NULL))); + $target_entity_en = EntityTest::create((array('langcode' => 'en', 'field_test_entity_reference' => NULL))); $target_entity_en->save(); // Create a German entity. @@ -55,7 +56,7 @@ public function testNormalize() { ) ); - $entity = entity_create('entity_test', $values); + $entity = EntityTest::create($values); $entity->save(); // Add an English value for name and entity reference properties. $entity->addTranslation('en')->set('name', array(0 => array('value' => $translation_values['name']))); diff --git a/core/modules/image/src/Tests/ImageItemTest.php b/core/modules/image/src/Tests/ImageItemTest.php index 983088f46120e500d87c4d3d51dbcdf2ea6e49c5..46826111475b7ae91c623801fdb6fce5b5351911 100644 --- a/core/modules/image/src/Tests/ImageItemTest.php +++ b/core/modules/image/src/Tests/ImageItemTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Entity\FieldStorageConfig; @@ -71,7 +72,7 @@ protected function setUp() { */ public function testImageItem() { // Create a test entity with the image field set. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->image_test->target_id = $this->image->id(); $entity->image_test->alt = $alt = $this->randomMachineName(); $entity->image_test->title = $title = $this->randomMachineName(); @@ -115,7 +116,7 @@ public function testImageItem() { // Delete the image and try to save the entity again. $this->image->delete(); - $entity = entity_create('entity_test', array('mame' => $this->randomMachineName())); + $entity = EntityTest::create(array('mame' => $this->randomMachineName())); $entity->save(); // Test image item properties. @@ -124,7 +125,7 @@ public function testImageItem() { $this->assertEqual(array_keys($properties), $expected); // Test the generateSampleValue() method. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->image_test->generateSampleItems(); $this->entityValidateAndSave($entity); } diff --git a/core/modules/image/src/Tests/ImageThemeFunctionTest.php b/core/modules/image/src/Tests/ImageThemeFunctionTest.php index 653ba557d2cd3fe47c071c1aba4a4fd92eecdbd1..e2f7e9e4709fbb131d37564d7108bdb5cfdb1f6f 100644 --- a/core/modules/image/src/Tests/ImageThemeFunctionTest.php +++ b/core/modules/image/src/Tests/ImageThemeFunctionTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Url; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\file\Entity\File; use Drupal\image\Entity\ImageStyle; @@ -81,7 +82,7 @@ function testImageFormatterTheme() { $url = file_url_transform_relative($style->buildUrl($original_uri)); // Create a test entity with the image field set. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->image_test->target_id = $this->image->id(); $entity->image_test->alt = NULL; $entity->image_test->uri = $original_uri; diff --git a/core/modules/link/src/Tests/LinkItemTest.php b/core/modules/link/src/Tests/LinkItemTest.php index 1115983f9334774b8210ebc92fcdd3389bf3aa43..870dc1a3c43b14f8dc1585b4ec38836f223ebce6 100644 --- a/core/modules/link/src/Tests/LinkItemTest.php +++ b/core/modules/link/src/Tests/LinkItemTest.php @@ -10,6 +10,7 @@ use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Tests\FieldUnitTestBase; @@ -73,7 +74,7 @@ protected function setUp() { */ public function testLinkItem() { // Create entity. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $url = 'https://www.drupal.org?test_param=test_value'; $parsed_url = UrlHelper::parse($url); $title = $this->randomMachineName(); @@ -158,7 +159,7 @@ public function testLinkItem() { // Test the generateSampleValue() method for generic, external, and internal // link types. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_test->generateSampleItems(); $entity->field_test_external->generateSampleItems(); $entity->field_test_internal->generateSampleItems(); diff --git a/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php b/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php index c54466dfb1d907b0b454b0c5836bf56d9f71ac88..ed1565d7faa02e30d9fdb08b0eb362aee8a6e9c8 100644 --- a/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php +++ b/core/modules/options/src/Tests/OptionsDynamicValuesTestBase.php @@ -10,6 +10,7 @@ use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\FieldTestBase; use Drupal\field\Entity\FieldStorageConfig; +use Drupal\entity_test\Entity\EntityTestRev; /** * Base class for testing allowed values of options fields. @@ -70,7 +71,7 @@ protected function setUp() { 'user_id' => mt_rand(1, 10), 'name' => $this->randomMachineName(), ]; - $this->entity = entity_create('entity_test_rev', $values); + $this->entity = EntityTestRev::create($values); $this->entity->save(); $this->test = [ 'label' => $this->entity->label(), diff --git a/core/modules/options/src/Tests/OptionsFieldTest.php b/core/modules/options/src/Tests/OptionsFieldTest.php index 98d9d099be731c08b1c3d140320d789de7aeb232..402c9b40ed034d8a873add482e46036cd8ed7d32 100644 --- a/core/modules/options/src/Tests/OptionsFieldTest.php +++ b/core/modules/options/src/Tests/OptionsFieldTest.php @@ -8,6 +8,7 @@ namespace Drupal\options\Tests; use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -30,7 +31,7 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase { */ function testUpdateAllowedValues() { // All three options appear. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $form = \Drupal::service('entity.form_builder')->getForm($entity); $this->assertTrue(!empty($form[$this->fieldName]['widget'][1]), 'Option 1 exists'); $this->assertTrue(!empty($form[$this->fieldName]['widget'][2]), 'Option 2 exists'); @@ -38,7 +39,7 @@ function testUpdateAllowedValues() { // Use one of the values in an actual entity, and check that this value // cannot be removed from the list. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$this->fieldName}->value = 1; $entity->save(); $this->fieldStorage->setSetting('allowed_values', [2 => 'Two']); @@ -56,7 +57,7 @@ function testUpdateAllowedValues() { // Removed options do not appear. $this->fieldStorage->setSetting('allowed_values', [2 => 'Two']); $this->fieldStorage->save(); - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $form = \Drupal::service('entity.form_builder')->getForm($entity); $this->assertTrue(empty($form[$this->fieldName]['widget'][1]), 'Option 1 does not exist'); $this->assertTrue(!empty($form[$this->fieldName]['widget'][2]), 'Option 2 exists'); @@ -67,7 +68,7 @@ function testUpdateAllowedValues() { $this->fieldStorage->save(); // The entity holds an outdated field object with the old allowed values // setting, so we need to reinitialize the entity object. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $form = \Drupal::service('entity.form_builder')->getForm($entity); $this->assertTrue(empty($form[$this->fieldName]['widget'][1]), 'Option 1 does not exist'); $this->assertTrue(empty($form[$this->fieldName]['widget'][2]), 'Option 2 does not exist'); @@ -89,14 +90,14 @@ function testUpdateAllowedValues() { 'type' => 'options_buttons', )) ->save(); - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $form = \Drupal::service('entity.form_builder')->getForm($entity); $this->assertTrue(!empty($form[$this->fieldName]['widget'][1]), 'Option 1 exists'); $this->assertTrue(!empty($form[$this->fieldName]['widget'][2]), 'Option 2 exists'); $this->assertTrue(!empty($form[$this->fieldName]['widget'][3]), 'Option 3 exists'); // Test the generateSampleValue() method. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$this->fieldName}->generateSampleItems(); $this->entityValidateAndSave($entity); } diff --git a/core/modules/options/src/Tests/OptionsFormattersTest.php b/core/modules/options/src/Tests/OptionsFormattersTest.php index 8d97ab433a87bb473587162aa1650c742e2468d1..eb63051b6dca5f5d481e3c1b916d4a25873f3f93 100644 --- a/core/modules/options/src/Tests/OptionsFormattersTest.php +++ b/core/modules/options/src/Tests/OptionsFormattersTest.php @@ -7,6 +7,8 @@ namespace Drupal\options\Tests; +use Drupal\entity_test\Entity\EntityTest; + /** * Tests the Options field type formatters. * @@ -27,7 +29,7 @@ protected function setUp() { * Tests the formatters. */ public function testFormatter() { - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$this->fieldName}->value = 1; $items = $entity->get($this->fieldName); diff --git a/core/modules/options/src/Tests/OptionsWidgetsTest.php b/core/modules/options/src/Tests/OptionsWidgetsTest.php index 679fdb6985fe42c30a0ee4ed37a9f8227b110621..58b666d2eea98dfb68797892159d24b427cafd0c 100644 --- a/core/modules/options/src/Tests/OptionsWidgetsTest.php +++ b/core/modules/options/src/Tests/OptionsWidgetsTest.php @@ -7,6 +7,7 @@ namespace Drupal\options\Tests; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\FieldTestBase; use Drupal\field\Entity\FieldStorageConfig; @@ -102,7 +103,7 @@ function testRadioButtons() { ->save(); // Create an entity. - $entity = entity_create('entity_test', [ + $entity = EntityTest::create([ 'user_id' => 1, 'name' => $this->randomMachineName(), ]); @@ -159,7 +160,7 @@ function testCheckBoxes() { ->save(); // Create an entity. - $entity = entity_create('entity_test', array( + $entity = EntityTest::create(array( 'user_id' => 1, 'name' => $this->randomMachineName(), )); @@ -249,7 +250,7 @@ function testSelectListSingle() { ->save(); // Create an entity. - $entity = entity_create('entity_test', array( + $entity = EntityTest::create(array( 'user_id' => 1, 'name' => $this->randomMachineName(), )); @@ -348,7 +349,7 @@ function testSelectListMultiple() { ->save(); // Create an entity. - $entity = entity_create('entity_test', array( + $entity = EntityTest::create(array( 'user_id' => 1, 'name' => $this->randomMachineName(), )); @@ -471,7 +472,7 @@ function testEmptyValue() { ->save(); // Create an entity. - $entity = entity_create('entity_test', [ + $entity = EntityTest::create([ 'user_id' => 1, 'name' => $this->randomMachineName(), ]); diff --git a/core/modules/quickedit/src/Tests/EditorSelectionTest.php b/core/modules/quickedit/src/Tests/EditorSelectionTest.php index 25e0095a03f11415c02a159693779ad0fd6e6717..dfc73f081c8affa790c6c88572f29003663eec47 100644 --- a/core/modules/quickedit/src/Tests/EditorSelectionTest.php +++ b/core/modules/quickedit/src/Tests/EditorSelectionTest.php @@ -7,6 +7,7 @@ namespace Drupal\quickedit\Tests; +use Drupal\entity_test\Entity\EntityTest; use Drupal\quickedit\EditorSelector; /** @@ -65,7 +66,7 @@ public function testText() { ); // Create an entity with values for this text field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$field_name}->value = 'Hello, world!'; $entity->save(); @@ -104,7 +105,7 @@ public function testTextWysiwyg() { ); // Create an entity with values for this text field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$field_name}->value = 'Hello, world!'; $entity->{$field_name}->format = 'filtered_html'; $entity->save(); @@ -141,7 +142,7 @@ public function testNumber() { ); // Create an entity with values for this text field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$field_name}->value = 42; $entity->save(); diff --git a/core/modules/quickedit/src/Tests/MetadataGeneratorTest.php b/core/modules/quickedit/src/Tests/MetadataGeneratorTest.php index 0ac570641d16bba3749e9e0601846a70959112d8..f4633e15ee10823cdb1318fe880237d3d1e38a43 100644 --- a/core/modules/quickedit/src/Tests/MetadataGeneratorTest.php +++ b/core/modules/quickedit/src/Tests/MetadataGeneratorTest.php @@ -7,6 +7,7 @@ namespace Drupal\quickedit\Tests; +use Drupal\entity_test\Entity\EntityTest; use Drupal\quickedit\EditorSelector; use Drupal\quickedit\MetadataGenerator; use Drupal\quickedit_test\MockEditEntityFieldAccessCheck; @@ -93,7 +94,7 @@ public function testSimpleEntityType() { ); // Create an entity with values for this text field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$field_1_name}->value = 'Test'; $entity->{$field_2_name}->value = 42; $entity->save(); @@ -159,7 +160,7 @@ public function testEditorWithCustomMetadata() { $full_html_format->save(); // Create an entity with values for this rich text field. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->{$field_name}->value = 'Test'; $entity->{$field_name}->format = 'full_html'; $entity->save(); diff --git a/core/modules/rdf/src/Tests/Field/DateTimeFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/DateTimeFieldRdfaTest.php index 1b47b404b2a0d0b735f330373a95b252c632d2ec..97b3c9aa5f66aa66f55dbefa60f04d8aa7eb1972 100644 --- a/core/modules/rdf/src/Tests/Field/DateTimeFieldRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/DateTimeFieldRdfaTest.php @@ -6,6 +6,8 @@ namespace Drupal\rdf\Tests\Field; +use Drupal\entity_test\Entity\EntityTest; + /** * Tests RDFa output by datetime field formatters. * @@ -42,7 +44,7 @@ protected function setUp() { ))->save(); // Set up test entity. - $this->entity = entity_create('entity_test', array()); + $this->entity = EntityTest::create(array()); $this->entity->{$this->fieldName}->value = $this->testValue; } diff --git a/core/modules/rdf/src/Tests/Field/EmailFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/EmailFieldRdfaTest.php index cda7ee7f61a6e114fa382c7bcbd991046e23791c..872bd24903636ae0f96cb76b9fd201c1eb16b9ac 100644 --- a/core/modules/rdf/src/Tests/Field/EmailFieldRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/EmailFieldRdfaTest.php @@ -6,6 +6,8 @@ namespace Drupal\rdf\Tests\Field; +use Drupal\entity_test\Entity\EntityTest; + /** * Tests RDFa output by email field formatters. * @@ -36,7 +38,7 @@ protected function setUp() { // Set up test values. $this->testValue = 'test@example.com'; - $this->entity = entity_create('entity_test', array()); + $this->entity = EntityTest::create(array()); $this->entity->{$this->fieldName}->value = $this->testValue; } diff --git a/core/modules/rdf/src/Tests/Field/FieldRdfaDatatypeCallbackTest.php b/core/modules/rdf/src/Tests/Field/FieldRdfaDatatypeCallbackTest.php index 0b43c30dd8f7aa08fcc37c7c65ad2e0ef36c17f8..612fba93ab043d63a548247124851307725a43d7 100644 --- a/core/modules/rdf/src/Tests/Field/FieldRdfaDatatypeCallbackTest.php +++ b/core/modules/rdf/src/Tests/Field/FieldRdfaDatatypeCallbackTest.php @@ -6,6 +6,8 @@ namespace Drupal\rdf\Tests\Field; +use Drupal\entity_test\Entity\EntityTest; + /** * Tests the RDFa output of a text field formatter with a datatype callback. * @@ -41,7 +43,7 @@ protected function setUp() { // Set up test values. $this->testValue = $this->randomMachineName(); - $this->entity = entity_create('entity_test'); + $this->entity = EntityTest::create(); $this->entity->{$this->fieldName}->value = $this->testValue; $this->entity->save(); diff --git a/core/modules/rdf/src/Tests/Field/LinkFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/LinkFieldRdfaTest.php index 3a58b80da2c4493569b94b15da35e1dd9144f2b8..01e6977e6da74d1a9146eae41b492c4bd28276d6 100644 --- a/core/modules/rdf/src/Tests/Field/LinkFieldRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/LinkFieldRdfaTest.php @@ -6,6 +6,8 @@ namespace Drupal\rdf\Tests\Field; +use Drupal\entity_test\Entity\EntityTest; + /** * Tests the placement of RDFa in link field formatters. * @@ -45,7 +47,7 @@ protected function setUp() { public function testAllFormattersExternal() { // Set up test values. $this->testValue = 'http://test.me/foo/bar/neque/porro/quisquam/est/qui-dolorem?foo/bar/neque/porro/quisquam/est/qui-dolorem'; - $this->entity = entity_create('entity_test', array()); + $this->entity = EntityTest::create(array()); $this->entity->{$this->fieldName}->uri = $this->testValue; // Set up the expected result. @@ -63,7 +65,7 @@ public function testAllFormattersExternal() { public function testAllFormattersInternal() { // Set up test values. $this->testValue = 'admin'; - $this->entity = entity_create('entity_test', array()); + $this->entity = EntityTest::create(array()); $this->entity->{$this->fieldName}->uri = 'internal:/admin'; // Set up the expected result. @@ -82,7 +84,7 @@ public function testAllFormattersInternal() { public function testAllFormattersFront() { // Set up test values. $this->testValue = '/'; - $this->entity = entity_create('entity_test', array()); + $this->entity = EntityTest::create(array()); $this->entity->{$this->fieldName}->uri = 'internal:/'; // Set up the expected result. diff --git a/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php index 84248666edad3748d5c895e6703cc2337f20efa9..69d81a81d8feff864612acd4689c13a294e1e789 100644 --- a/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/NumberFieldRdfaTest.php @@ -6,6 +6,8 @@ namespace Drupal\rdf\Tests\Field; +use Drupal\entity_test\Entity\EntityTest; + /** * Tests RDFa output by number field formatters. * @@ -199,7 +201,7 @@ protected function createTestEntity($testValue) { ))->save(); // Set up test entity. - $this->entity = entity_create('entity_test', array()); + $this->entity = EntityTest::create(array()); $this->entity->{$this->fieldName}->value = $testValue; } } diff --git a/core/modules/rdf/src/Tests/Field/StringFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/StringFieldRdfaTest.php index 9805682ad9d61138c508966666f43df94d1daf8a..8856c2035d993d4008d276f82b168d72dbed020d 100644 --- a/core/modules/rdf/src/Tests/Field/StringFieldRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/StringFieldRdfaTest.php @@ -6,6 +6,8 @@ namespace Drupal\rdf\Tests\Field; +use Drupal\entity_test\Entity\EntityTest; + /** * Tests RDFa output by text field formatters. * @@ -44,7 +46,7 @@ protected function setUp() { ))->save(); // Set up test entity. - $this->entity = entity_create('entity_test'); + $this->entity = EntityTest::create(); $this->entity->{$this->fieldName}->value = $this->testValue; $this->entity->{$this->fieldName}->summary = $this->testSummary; } diff --git a/core/modules/rdf/src/Tests/Field/TelephoneFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/TelephoneFieldRdfaTest.php index 002db43a0dfd062004bb641f00e04a2b8078fc01..dad5c4a111b84420397a8d1d8dc53cd686b26edc 100644 --- a/core/modules/rdf/src/Tests/Field/TelephoneFieldRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/TelephoneFieldRdfaTest.php @@ -6,6 +6,8 @@ namespace Drupal\rdf\Tests\Field; +use Drupal\entity_test\Entity\EntityTest; + /** * Tests RDFa output by telephone field formatters. * @@ -43,7 +45,7 @@ protected function setUp() { // Set up test values. $this->testValue = '555-555-5555'; - $this->entity = entity_create('entity_test', array()); + $this->entity = EntityTest::create(array()); $this->entity->{$this->fieldName}->value = $this->testValue; } diff --git a/core/modules/rdf/src/Tests/Field/TextFieldRdfaTest.php b/core/modules/rdf/src/Tests/Field/TextFieldRdfaTest.php index 0e97b272257d8fd953df6150ad2419ad7e220454..2f0cd4656e26a919864f8325abfed80585c5d18a 100644 --- a/core/modules/rdf/src/Tests/Field/TextFieldRdfaTest.php +++ b/core/modules/rdf/src/Tests/Field/TextFieldRdfaTest.php @@ -6,6 +6,8 @@ namespace Drupal\rdf\Tests\Field; +use Drupal\entity_test\Entity\EntityTest; + /** * Tests RDFa output by text field formatters. * @@ -51,7 +53,7 @@ protected function setUp() { ))->save(); // Set up test entity. - $this->entity = entity_create('entity_test'); + $this->entity = EntityTest::create(); $this->entity->{$this->fieldName}->value = $this->testValue; $this->entity->{$this->fieldName}->summary = $this->testSummary; } diff --git a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php index b590504dc2e7795607841bddb0c834de60b5fa99..7e882a68acf5e2ee98aa444a531a8c5ae59a2e64 100644 --- a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php +++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php @@ -66,7 +66,7 @@ protected function setUp() { // Save some entity_test entities. for ($i = 1; $i <= 10; $i++) { - entity_create('entity_test', array('name' => 'test_' . $i, 'user_id' => $this->adminUser->id()))->save(); + EntityTest::create(array('name' => 'test_' . $i, 'user_id' => $this->adminUser->id()))->save(); } $this->enableViewsTestModule(); diff --git a/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.install b/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.install index f5b4a3929537bae373cb4bf37114653afbe3eb35..447a192f4119e88784328c90045bc55bbbc9c28d 100644 --- a/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.install +++ b/core/modules/simpletest/tests/modules/simpletest_test/simpletest_test.install @@ -5,6 +5,8 @@ * Install hooks for test module. */ +use Drupal\entity_test\Entity\EntityTest; + /** * Implements hook_install(). */ @@ -27,6 +29,6 @@ function simpletest_test_install() { * Callback for batch operations. */ function _simpletest_test_callback($id) { - $entity = entity_create('entity_test', array('id' => $id)); + $entity = EntityTest::create(array('id' => $id)); $entity->save(); } diff --git a/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php b/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php index bea9af41838df8e5ae485c20fe05da85d7d8694d..222cd7a1ead4eda5a581df5dbe671ded10cc8f6b 100644 --- a/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php +++ b/core/modules/system/src/Tests/Entity/EntityAccessControlHandlerTest.php @@ -11,6 +11,8 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessibleInterface; use Drupal\Core\Entity\EntityAccessControlHandler; +use Drupal\entity_test\Entity\EntityTest; +use Drupal\entity_test\Entity\EntityTestDefaultAccess; use Drupal\language\Entity\ConfigurableLanguage; /** @@ -40,7 +42,7 @@ function assertEntityAccess($ops, AccessibleInterface $object, AccountInterface function testEntityAccess() { // Set up a non-admin user that is allowed to view test entities. \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2), array('view test entity'))); - $entity = entity_create('entity_test', array( + $entity = EntityTest::create(array( 'name' => 'test', )); @@ -77,7 +79,7 @@ function testEntityAccess() { function testDefaultEntityAccess() { // Set up a non-admin user that is allowed to view test entities. \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2), array('view test entity'))); - $entity = entity_create('entity_test', array( + $entity = EntityTest::create(array( 'name' => 'forbid_access', )); @@ -102,7 +104,7 @@ function testEntityAccessDefaultController() { $handler = $this->container->get('entity.manager')->getAccessControlHandler('entity_test_default_access'); $this->assertTrue($handler instanceof EntityAccessControlHandler, 'The default entity handler is used for the entity_test_default_access entity type.'); - $entity = entity_create('entity_test_default_access'); + $entity = EntityTestDefaultAccess::create(); $this->assertEntityAccess(array( 'create' => FALSE, 'update' => FALSE, @@ -127,7 +129,7 @@ function testEntityTranslationAccess() { ))->save(); } - $entity = entity_create('entity_test', array( + $entity = EntityTest::create(array( 'name' => 'test', 'langcode' => 'foo', )); @@ -144,7 +146,7 @@ function testEntityTranslationAccess() { */ public function testHooks() { $state = $this->container->get('state'); - $entity = entity_create('entity_test', array( + $entity = EntityTest::create(array( 'name' => 'test', )); diff --git a/core/modules/system/src/Tests/Entity/EntityApiTest.php b/core/modules/system/src/Tests/Entity/EntityApiTest.php index e8153ce607d040789e41138780220bbc065b0d7b..7445734107b7c2936682d1f96d65c99d39384f14 100644 --- a/core/modules/system/src/Tests/Entity/EntityApiTest.php +++ b/core/modules/system/src/Tests/Entity/EntityApiTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\Core\Entity\EntityStorageException; +use Drupal\entity_test\Entity\EntityTest; use Drupal\user\UserInterface; /** @@ -126,7 +127,7 @@ protected function assertCRUD($entity_type, UserInterface $user1) { * Tests that exceptions are thrown when saving or deleting an entity. */ public function testEntityStorageExceptionHandling() { - $entity = entity_create('entity_test', array('name' => 'test')); + $entity = EntityTest::create(array('name' => 'test')); try { $GLOBALS['entity_test_throw_exception'] = TRUE; $entity->save(); @@ -136,7 +137,7 @@ public function testEntityStorageExceptionHandling() { $this->assertEqual($e->getcode(), 1, 'Entity presave EntityStorageException caught.'); } - $entity = entity_create('entity_test', array('name' => 'test2')); + $entity = EntityTest::create(array('name' => 'test2')); try { unset($GLOBALS['entity_test_throw_exception']); $entity->save(); @@ -146,7 +147,7 @@ public function testEntityStorageExceptionHandling() { $this->assertNotEqual($e->getCode(), 1, 'Entity presave EntityStorageException caught.'); } - $entity = entity_create('entity_test', array('name' => 'test3')); + $entity = EntityTest::create(array('name' => 'test3')); $entity->save(); try { $GLOBALS['entity_test_throw_exception'] = TRUE; @@ -158,7 +159,7 @@ public function testEntityStorageExceptionHandling() { } unset($GLOBALS['entity_test_throw_exception']); - $entity = entity_create('entity_test', array('name' => 'test4')); + $entity = EntityTest::create(array('name' => 'test4')); $entity->save(); try { $entity->delete(); diff --git a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php index 8e401cd9cd161aa70ec8d6554a656fb9e08f9a46..0ba6e34cbaf77358b85ce658c1670bb9f9102d16 100644 --- a/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php +++ b/core/modules/system/src/Tests/Entity/EntityCrudHookTest.php @@ -13,6 +13,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Language\LanguageInterface; use Drupal\block\Entity\Block; +use Drupal\entity_test\Entity\EntityTest; use Drupal\node\Entity\NodeType; use Drupal\taxonomy\Entity\Term; use Drupal\node\Entity\Node; @@ -542,7 +543,7 @@ public function testUserHooks() { function testEntityRollback() { // Create a block. try { - entity_create('entity_test', array('name' => 'fail_insert'))->save(); + EntityTest::create(array('name' => 'fail_insert'))->save(); $this->fail('Expected exception has not been thrown.'); } catch (\Exception $e) { diff --git a/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php b/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php index f38c62dfca2354d46350ea28857ec920d5db9374..ec2ac42d18af62a501117cb3e2b9155406eb816a 100644 --- a/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php +++ b/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\Core\Language\LanguageInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\simpletest\WebTestBase; /** @@ -41,7 +42,7 @@ protected function setUp() { public function testPager() { // Create 51 test entities. for ($i = 1; $i < 52; $i++) { - entity_create('entity_test', array('name' => 'Test entity ' . $i))->save(); + EntityTest::create(array('name' => 'Test entity ' . $i))->save(); } // Load the listing page. diff --git a/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php b/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php index 02a156657090f2d9d14460c770c125923e4b2312..fdc7194556cfb40366964eaa58b93fb8e085078a 100644 --- a/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php +++ b/core/modules/system/src/Tests/Entity/EntityQueryRelationshipTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\Component\Utility\Unicode; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait; /** @@ -102,7 +103,7 @@ protected function setUp() { // 0th account and 0th term, the 1st and 2nd entity will point to the // 1st account and 1st term. for ($i = 0; $i <= 2; $i++) { - $entity = entity_create('entity_test', array('type' => 'test_bundle')); + $entity = EntityTest::create(array('type' => 'test_bundle')); $entity->name->value = $this->randomMachineName(); $index = $i ? 1 : 0; $entity->user_id->target_id = $this->accounts[$index]->id(); diff --git a/core/modules/system/src/Tests/Entity/EntityQueryTest.php b/core/modules/system/src/Tests/Entity/EntityQueryTest.php index a36829842215dfa1f6a590efa374be3bdf13869c..eb5a9494e66065417095d2cceff9af0d1ab480ca 100644 --- a/core/modules/system/src/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/src/Tests/Entity/EntityQueryTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\Component\Utility\Unicode; +use Drupal\entity_test\Entity\EntityTest; use Drupal\entity_test\Entity\EntityTestMulRev; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -472,7 +473,7 @@ public function testCount() { 'bundle' => $bundle, ])->save(); - $entity = entity_create('entity_test', array( + $entity = EntityTest::create(array( 'id' => 1, 'type' => $bundle, )); diff --git a/core/modules/system/src/Tests/Entity/EntityReferenceFieldTest.php b/core/modules/system/src/Tests/Entity/EntityReferenceFieldTest.php index aa49b84de565577e8b36dc1d5889f7aa93cb70a1..33379bc4d605356721ee05b65c1a90192f76f33d 100644 --- a/core/modules/system/src/Tests/Entity/EntityReferenceFieldTest.php +++ b/core/modules/system/src/Tests/Entity/EntityReferenceFieldTest.php @@ -19,6 +19,7 @@ use Drupal\user\Entity\User; use Drupal\user\RoleInterface; use Drupal\user\UserInterface; +use Drupal\entity_test\Entity\EntityTestStringId; /** * Tests for the entity reference field. @@ -202,7 +203,10 @@ public function testReferencedEntitiesStringId() { $entity = entity_create($this->entityType, array('type' => $this->bundle)); // Create the default target entity. - $target_entity = entity_create('entity_test_string_id', array('id' => $this->randomString(), 'type' => $this->bundle)); + $target_entity = EntityTestStringId::create([ + 'id' => $this->randomString(), + 'type' => $this->bundle + ]); $target_entity->save(); // Set the field value. diff --git a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php index 5e8e5fa81efde0899980b14772e13fa8e310c795..81ffb6790238fd6c6431e25c28378969ca667a9b 100644 --- a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php +++ b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Entity; +use Drupal\entity_test\Entity\EntityTest; use Drupal\simpletest\WebTestBase; /** @@ -84,7 +85,7 @@ public function testFieldItemAttributes() { // Create an entity and save test value in field_test_text. $test_value = $this->randomMachineName(); - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_test_text = $test_value; $entity->save(); diff --git a/core/modules/system/src/Tests/Entity/FieldAccessTest.php b/core/modules/system/src/Tests/Entity/FieldAccessTest.php index 0e4fe592636e7ec5b1bf10f9d399a348541c9f15..a6a677f677b2d92e86b9809503bdd6003735fd8b 100644 --- a/core/modules/system/src/Tests/Entity/FieldAccessTest.php +++ b/core/modules/system/src/Tests/Entity/FieldAccessTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Entity; use Drupal\Core\Access\AccessResult; +use Drupal\entity_test\Entity\EntityTest; use Drupal\simpletest\KernelTestBase; use Drupal\user\Entity\User; @@ -61,7 +62,7 @@ function testFieldAccess() { 'format' => 'full_html', ), ); - $entity = entity_create('entity_test', $values); + $entity = EntityTest::create($values); // Create a dummy user account for testing access with. $values = array('name' => 'test'); diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index 3f8edd16a66a65204ad80b811a989799b1fe2675..24b4d54d6d398dec468cb88a0ecd94aa34672a7c 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -9,6 +9,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use \Drupal\Core\Extension\ModuleUninstallValidatorException; +use Drupal\entity_test\Entity\EntityTest; use Drupal\KernelTests\KernelTestBase; /** @@ -238,7 +239,7 @@ function testUninstallContentDependency() { drupal_static_reset('system_rebuild_module_data'); // Create an entity so that the modules can not be disabled. - $entity = entity_create('entity_test', array('name' => $this->randomString())); + $entity = EntityTest::create(array('name' => $this->randomString())); $entity->save(); // Uninstalling entity_test is not possible when there is content. diff --git a/core/modules/telephone/src/Tests/TelephoneItemTest.php b/core/modules/telephone/src/Tests/TelephoneItemTest.php index be0163f23b18c10d2d2ead943d88401ea5cb5d08..53edffa6bb3f19ad8d590f21631f19739dc12be5 100644 --- a/core/modules/telephone/src/Tests/TelephoneItemTest.php +++ b/core/modules/telephone/src/Tests/TelephoneItemTest.php @@ -9,6 +9,7 @@ use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemInterface; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Entity\FieldStorageConfig; @@ -48,7 +49,7 @@ protected function setUp() { */ public function testTestItem() { // Verify entity creation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $value = '+0123456789'; $entity->field_test = $value; $entity->name->value = $this->randomMachineName(); @@ -73,7 +74,7 @@ public function testTestItem() { $this->assertEqual($entity->field_test->value, $new_value); // Test sample item generation. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); $entity->field_test->generateSampleItems(); $this->entityValidateAndSave($entity); } diff --git a/core/modules/text/src/Tests/TextFieldTest.php b/core/modules/text/src/Tests/TextFieldTest.php index 13df9662d830a7cc8b4f1ca26e48aa37e44396d2..9d440036ef1b647dd0301a3d00c10e927f37cdc6 100644 --- a/core/modules/text/src/Tests/TextFieldTest.php +++ b/core/modules/text/src/Tests/TextFieldTest.php @@ -8,6 +8,7 @@ namespace Drupal\text\Tests; use Drupal\Component\Utility\Unicode; +use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Tests\String\StringFieldTest; use Drupal\field\Entity\FieldStorageConfig; @@ -56,7 +57,7 @@ function testTextFieldValidation() { ])->save(); // Test validation with valid and invalid values. - $entity = entity_create('entity_test'); + $entity = EntityTest::create(); for ($i = 0; $i <= $max_length + 2; $i++) { $entity->{$field_name}->value = str_repeat('x', $i); $violations = $entity->{$field_name}->validate();