Commit 98d39d1b authored by alexpott's avatar alexpott

Issue #2669400 by jungle, dimaro, rakesh.gectcr, lluvigne, Mile23: Replace...

Issue #2669400 by jungle, dimaro, rakesh.gectcr, lluvigne, Mile23: Replace deprecated usages of entity_create('type') with a direct call to <EntityType>::create()
parent e5b24859
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use Drupal\comment\CommentManagerInterface; use Drupal\comment\CommentManagerInterface;
use Drupal\comment\Entity\Comment; use Drupal\comment\Entity\Comment;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase; use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
use Drupal\user\Entity\Role; use Drupal\user\Entity\Role;
...@@ -70,7 +71,7 @@ protected function createEntity() { ...@@ -70,7 +71,7 @@ protected function createEntity() {
$field->save(); $field->save();
// Create a "Camelids" test entity that the comment will be assigned to. // 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', 'name' => 'Camelids',
'type' => 'bar', 'type' => 'bar',
)); ));
...@@ -101,7 +102,7 @@ public function testCommentEntity() { ...@@ -101,7 +102,7 @@ public function testCommentEntity() {
$this->verifyPageCache($this->entityTestCamelid->urlInfo(), 'HIT'); $this->verifyPageCache($this->entityTestCamelid->urlInfo(), 'HIT');
// Create a "Hippopotamus" comment. // Create a "Hippopotamus" comment.
$this->entityTestHippopotamidae = entity_create('entity_test', array( $this->entityTestHippopotamidae = EntityTest::create(array(
'name' => 'Hippopotamus', 'name' => 'Hippopotamus',
'type' => 'bar', 'type' => 'bar',
)); ));
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Session;
use Drupal\comment\Entity\Comment; use Drupal\comment\Entity\Comment;
use Drupal\entity_test\Entity\EntityTest;
/** /**
* Tests the bubbling up of comment cache tags when using the Comment list * Tests the bubbling up of comment cache tags when using the Comment list
...@@ -74,7 +75,7 @@ public function testCacheTags() { ...@@ -74,7 +75,7 @@ public function testCacheTags() {
$renderer = $this->container->get('renderer'); $renderer = $this->container->get('renderer');
// Create the entity that will be commented upon. // 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(); $commented_entity->save();
// Verify cache tags on the rendered entity before it has comments. // Verify cache tags on the rendered entity before it has comments.
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Tests\FieldUnitTestBase;
/** /**
...@@ -40,7 +41,7 @@ public function testCommentItem() { ...@@ -40,7 +41,7 @@ public function testCommentItem() {
$this->addDefaultCommentField('entity_test', 'entity_test', 'comment'); $this->addDefaultCommentField('entity_test', 'entity_test', 'comment');
// Verify entity creation. // Verify entity creation.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$entity->name->value = $this->randomMachineName(); $entity->name->value = $this->randomMachineName();
$entity->save(); $entity->save();
...@@ -52,7 +53,7 @@ public function testCommentItem() { ...@@ -52,7 +53,7 @@ public function testCommentItem() {
// Test sample item generation. // Test sample item generation.
/** @var \Drupal\entity_test\Entity\EntityTest $entity */ /** @var \Drupal\entity_test\Entity\EntityTest $entity */
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$entity->comment->generateSampleItems(); $entity->comment->generateSampleItems();
$this->entityValidateAndSave($entity); $this->entityValidateAndSave($entity);
$this->assertTrue(in_array($entity->get('comment')->status, [ $this->assertTrue(in_array($entity->get('comment')->status, [
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use Drupal\comment\Entity\Comment; use Drupal\comment\Entity\Comment;
use Drupal\comment\Entity\CommentType; use Drupal\comment\Entity\CommentType;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field_ui\Tests\FieldUiTestTrait; use Drupal\field_ui\Tests\FieldUiTestTrait;
...@@ -92,7 +93,7 @@ protected function setUp() { ...@@ -92,7 +93,7 @@ protected function setUp() {
// Create a test entity. // Create a test entity.
$random_label = $this->randomMachineName(); $random_label = $this->randomMachineName();
$data = array('type' => 'entity_test', 'name' => $random_label); $data = array('type' => 'entity_test', 'name' => $random_label);
$this->entity = entity_create('entity_test', $data); $this->entity = EntityTest::create($data);
$this->entity->save(); $this->entity->save();
} }
...@@ -433,7 +434,7 @@ function testCommentFunctionality() { ...@@ -433,7 +434,7 @@ function testCommentFunctionality() {
// Test the new entity commenting inherits default. // Test the new entity commenting inherits default.
$random_label = $this->randomMachineName(); $random_label = $this->randomMachineName();
$data = array('bundle' => 'entity_test', 'name' => $random_label); $data = array('bundle' => 'entity_test', 'name' => $random_label);
$new_entity = entity_create('entity_test', $data); $new_entity = EntityTest::create($data);
$new_entity->save(); $new_entity->save();
$this->drupalGet('entity_test/manage/' . $new_entity->id() . '/edit'); $this->drupalGet('entity_test/manage/' . $new_entity->id() . '/edit');
$this->assertNoFieldChecked('edit-field-foobar-0-status-1'); $this->assertNoFieldChecked('edit-field-foobar-0-status-1');
......
...@@ -115,7 +115,7 @@ public function testDependencyManagement() { ...@@ -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.'); $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. // Test dependency on a content entity.
$entity_test = entity_create('entity_test', array( $entity_test = EntityTest::create(array(
'name' => $this->randomString(), 'name' => $this->randomString(),
'type' => 'entity_test', 'type' => 'entity_test',
)); ));
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Core\Config\ConfigImporter; use Drupal\Core\Config\ConfigImporter;
use Drupal\Core\Config\StorageComparer; use Drupal\Core\Config\StorageComparer;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\simpletest\KernelTestBase; use Drupal\simpletest\KernelTestBase;
/** /**
...@@ -77,9 +78,9 @@ function testMissingContent() { ...@@ -77,9 +78,9 @@ function testMissingContent() {
// on two content entities that do not exist. // on two content entities that do not exist.
$storage = $this->container->get('config.storage'); $storage = $this->container->get('config.storage');
$sync = $this->container->get('config.storage.sync'); $sync = $this->container->get('config.storage.sync');
$entity_one = entity_create('entity_test', array('name' => 'one')); $entity_one = EntityTest::create(array('name' => 'one'));
$entity_two = entity_create('entity_test', array('name' => 'two')); $entity_two = EntityTest::create(array('name' => 'two'));
$entity_three = entity_create('entity_test', array('name' => 'three')); $entity_three = EntityTest::create(array('name' => 'three'));
$dynamic_name = 'config_test.dynamic.dotted.default'; $dynamic_name = 'config_test.dynamic.dotted.default';
$original_dynamic_data = $storage->read($dynamic_name); $original_dynamic_data = $storage->read($dynamic_name);
// Entity one will be resolved by // Entity one will be resolved by
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
...@@ -53,7 +54,7 @@ protected function setUp() { ...@@ -53,7 +54,7 @@ protected function setUp() {
*/ */
public function testDateTimeItem() { public function testDateTimeItem() {
// Verify entity creation. // Verify entity creation.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$value = '2014-01-01T20:00:00Z'; $value = '2014-01-01T20:00:00Z';
$entity->field_datetime = $value; $entity->field_datetime = $value;
$entity->name->value = $this->randomMachineName(); $entity->name->value = $this->randomMachineName();
...@@ -78,7 +79,7 @@ public function testDateTimeItem() { ...@@ -78,7 +79,7 @@ public function testDateTimeItem() {
$this->assertEqual($entity->field_datetime->value, $new_value); $this->assertEqual($entity->field_datetime->value, $new_value);
// Test the generateSampleValue() method. // Test the generateSampleValue() method.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$entity->field_datetime->generateSampleItems(); $entity->field_datetime->generateSampleItems();
$this->entityValidateAndSave($entity); $this->entityValidateAndSave($entity);
} }
...@@ -88,7 +89,7 @@ public function testDateTimeItem() { ...@@ -88,7 +89,7 @@ public function testDateTimeItem() {
*/ */
public function testSetValue() { public function testSetValue() {
// Test DateTimeItem::setValue() using string. // Test DateTimeItem::setValue() using string.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$value = '2014-01-01T20:00:00Z'; $value = '2014-01-01T20:00:00Z';
$entity->get('field_datetime')->set(0, $value); $entity->get('field_datetime')->set(0, $value);
$entity->save(); $entity->save();
...@@ -98,7 +99,7 @@ public function testSetValue() { ...@@ -98,7 +99,7 @@ public function testSetValue() {
$this->assertEqual($entity->field_datetime[0]->value, $value, 'DateTimeItem::setValue() works with string value.'); $this->assertEqual($entity->field_datetime[0]->value, $value, 'DateTimeItem::setValue() works with string value.');
// Test DateTimeItem::setValue() using property array. // Test DateTimeItem::setValue() using property array.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$value = '2014-01-01T20:00:00Z'; $value = '2014-01-01T20:00:00Z';
$entity->set('field_datetime', $value); $entity->set('field_datetime', $value);
$entity->save(); $entity->save();
...@@ -113,7 +114,7 @@ public function testSetValue() { ...@@ -113,7 +114,7 @@ public function testSetValue() {
*/ */
public function testSetValueProperty() { public function testSetValueProperty() {
// Test Date::setValue(). // Test Date::setValue().
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$value = '2014-01-01T20:00:00Z'; $value = '2014-01-01T20:00:00Z';
$entity->set('field_datetime', $value); $entity->set('field_datetime', $value);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
use Drupal\Core\EventSubscriber\AjaxResponseSubscriber; use Drupal\Core\EventSubscriber\AjaxResponseSubscriber;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
use Drupal\editor\Entity\Editor; use Drupal\editor\Entity\Editor;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\quickedit\MetadataGenerator; use Drupal\quickedit\MetadataGenerator;
use Drupal\quickedit\Tests\QuickEditTestBase; use Drupal\quickedit\Tests\QuickEditTestBase;
use Drupal\quickedit_test\MockEditEntityFieldAccessCheck; use Drupal\quickedit_test\MockEditEntityFieldAccessCheck;
...@@ -143,7 +144,7 @@ public function testEditorSelection() { ...@@ -143,7 +144,7 @@ public function testEditorSelection() {
$this->editorSelector = $this->container->get('quickedit.editor.selector'); $this->editorSelector = $this->container->get('quickedit.editor.selector');
// Create an entity with values for this text field. // 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}->value = 'Hello, world!';
$entity->{$this->fieldName}->format = 'filtered_html'; $entity->{$this->fieldName}->format = 'filtered_html';
$entity->save(); $entity->save();
...@@ -172,7 +173,7 @@ public function testMetadata() { ...@@ -172,7 +173,7 @@ public function testMetadata() {
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager); $this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
// Create an entity with values for the field. // Create an entity with values for the field.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$entity->{$this->fieldName}->value = 'Test'; $entity->{$this->fieldName}->value = 'Test';
$entity->{$this->fieldName}->format = 'full_html'; $entity->{$this->fieldName}->format = 'full_html';
$entity->save(); $entity->save();
...@@ -209,7 +210,7 @@ public function testAttachments() { ...@@ -209,7 +210,7 @@ public function testAttachments() {
*/ */
public function testGetUntransformedTextCommand() { public function testGetUntransformedTextCommand() {
// Create an entity with values for the field. // Create an entity with values for the field.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$entity->{$this->fieldName}->value = 'Test'; $entity->{$this->fieldName}->value = 'Test';
$entity->{$this->fieldName}->format = 'full_html'; $entity->{$this->fieldName}->format = 'full_html';
$entity->save(); $entity->save();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
...@@ -51,7 +52,7 @@ protected function setUp() { ...@@ -51,7 +52,7 @@ protected function setUp() {
*/ */
public function testBooleanItem() { public function testBooleanItem() {
// Verify entity creation. // Verify entity creation.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$value = '1'; $value = '1';
$entity->field_boolean = $value; $entity->field_boolean = $value;
$entity->name->value = $this->randomMachineName(); $entity->name->value = $this->randomMachineName();
...@@ -76,7 +77,7 @@ public function testBooleanItem() { ...@@ -76,7 +77,7 @@ public function testBooleanItem() {
$this->assertEqual($entity->field_boolean->value, $new_value); $this->assertEqual($entity->field_boolean->value, $new_value);
// Test sample item generation. // Test sample item generation.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$entity->field_boolean->generateSampleItems(); $entity->field_boolean->generateSampleItems();
$this->entityValidateAndSave($entity); $this->entityValidateAndSave($entity);
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\field\Tests; namespace Drupal\field\Tests;
use Drupal\Core\Entity\Entity\EntityViewMode; use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
...@@ -110,7 +111,7 @@ protected function setUp() { ...@@ -110,7 +111,7 @@ protected function setUp() {
// Create an entity with values. // Create an entity with values.
$this->values = $this->_generateTestFieldValues($this->cardinality); $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->{$this->fieldName}->setValue($this->values);
$this->entity->save(); $this->entity->save();
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemInterface; use Drupal\Core\Field\FieldItemInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\field\Tests\FieldUnitTestBase; use Drupal\field\Tests\FieldUnitTestBase;
use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
...@@ -48,7 +49,7 @@ protected function setUp() { ...@@ -48,7 +49,7 @@ protected function setUp() {
*/ */
public function testEmailItem() { public function testEmailItem() {
// Verify entity creation. // Verify entity creation.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$value = 'test@example.com'; $value = 'test@example.com';
$entity->field_email = $value; $entity->field_email = $value;
$entity->name->value = $this->randomMachineName(); $entity->name->value = $this->randomMachineName();
...@@ -73,7 +74,7 @@ public function testEmailItem() { ...@@ -73,7 +74,7 @@ public function testEmailItem() {
$this->assertEqual($entity->field_email->value, $new_value); $this->assertEqual($entity->field_email->value, $new_value);
// Test sample item generation. // Test sample item generation.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$entity->field_email->generateSampleItems(); $entity->field_email->generateSampleItems();
$this->entityValidateAndSave($entity); $this->entityValidateAndSave($entity);
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\SafeMarkup;
use Drupal\config\Tests\AssertConfigEntityImportTrait; use Drupal\config\Tests\AssertConfigEntityImportTrait;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase; use Drupal\simpletest\WebTestBase;
...@@ -202,9 +203,9 @@ protected function getTestEntities() { ...@@ -202,9 +203,9 @@ protected function getTestEntities() {
$config_entity_2 = entity_create('config_test', array('id' => $this->randomMachineName(), 'label' => $this->randomMachineName())); $config_entity_2 = entity_create('config_test', array('id' => $this->randomMachineName(), 'label' => $this->randomMachineName()));
$config_entity_2->save(); $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_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(); $content_entity_2->save();
return array( return array(
......
...@@ -115,7 +115,7 @@ public function testContentEntityReferenceItem() { ...@@ -115,7 +115,7 @@ public function testContentEntityReferenceItem() {
$tid = $this->term->id(); $tid = $this->term->id();
// Just being able to create the entity like this verifies a lot of code. // 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->field_test_taxonomy_term->target_id = $tid;
$entity->name->value = $this->randomMachineName(); $entity->name->value = $this->randomMachineName();
$entity->save(); $entity->save();
...@@ -178,11 +178,11 @@ public function testContentEntityReferenceItem() { ...@@ -178,11 +178,11 @@ public function testContentEntityReferenceItem() {
// Delete terms so we have nothing to reference and try again // Delete terms so we have nothing to reference and try again
$term->delete(); $term->delete();
$term2->delete(); $term2->delete();
$entity = entity_create('entity_test', array('name' => $this->randomMachineName())); $entity = EntityTest::create(array('name' => $this->randomMachineName()));
$entity->save(); $entity->save();
// Test the generateSampleValue() method. // Test the generateSampleValue() method.
$entity = entity_create('entity_test'); $entity = EntityTest::create();
$entity->field_test_taxonomy_term->generateSampleItems(); $entity->field_test_taxonomy_term->generateSampleItems();
$entity->field_test_taxonomy_vocabulary->generateSampleItems(); $entity->field_test_taxonomy_vocabulary->generateSampleItems();
$this->entityValidateAndSave($entity); $this->entityValidateAndSave($entity);
...@@ -211,7 +211,7 @@ public function testConfigEntityReferenceItem() { ...@@ -211,7 +211,7 @@ public function testConfigEntityReferenceItem() {
$referenced_entity_id = $this->vocabulary->id(); $referenced_entity_id = $this->vocabulary->id();
// Just being able to create the entity like this verifies a lot of code. // 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->field_test_taxonomy_vocabulary->target_id = $referenced_entity_id;
$entity->name->value = $this->randomMachineName(); $entity->name->value = $this->randomMachineName();
$entity->save(); $entity->save();
...@@ -247,7 +247,7 @@ public function testConfigEntityReferenceItem() { ...@@ -247,7 +247,7 @@ public function testConfigEntityReferenceItem() {
// Delete terms so we have nothing to reference and try again // Delete terms so we have nothing to reference and try again
$this->vocabulary->delete(); $this->vocabulary->delete();
$vocabulary2->delete(); $vocabulary2->delete();
$entity = entity_create('entity_test', array('name' => $this->randomMachineName())); $entity = EntityTest::create(array('name' => $this->randomMachineName()));
$entity->save(); $entity->save();
} }
...@@ -285,7 +285,7 @@ public function testEntitySaveOrder() { ...@@ -285,7 +285,7 @@ public function testEntitySaveOrder() {
'vid' => $this->term->bundle(), 'vid' => $this->term->bundle(),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
)); ));
$entity = entity_create('entity_test'); $entity = EntityTest::create();
// Now assign the unsaved term to the field. // Now assign the unsaved term to the field.
$entity->field_test_taxonomy_term->entity = $term; $entity->field_test_taxonomy_term->entity = $term;
$entity->name->value = $this->randomMachineName(); $entity->name->value = $this->randomMachineName();
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\field\Tests; namespace Drupal\field\Tests;
use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormState;
use Drupal\entity_test\Entity\EntityTest;
/** /**
* Tests other Field API functions. * Tests other Field API functions.
...@@ -143,9 +144,9 @@ function testEntityDisplayViewMultiple() { ...@@ -143,9 +144,9 @@ function testEntityDisplayViewMultiple() {
)); ));
// Create two entities. // 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)); $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)); $entity2->{$this->fieldTestData->field_name}->setValue($this->_generateTestFieldValues(1));
// Run buildMultiple(), and check that the entities come out as expected. // Run buildMultiple(), and check that the entities come out as expected.
...@@ -164,7 +165,7 @@ function testEntityDisplayViewMultiple() { ...@@ -164,7 +165,7 @@ function testEntityDisplayViewMultiple() {
*/ */
function testEntityCache() { function testEntityCache() {
// Initialize random values and a test entity. // 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()); $values = $this->_generateTestFieldValues($this->fieldTestData->field_storage->getCardinality());
// Non-cacheable entity type. // Non-cacheable entity type.
......
...@@ -291,7 +291,7 @@ function testDeleteFieldCrossDeletion() { ...@@ -291,7 +291,7 @@ function testDeleteFieldCrossDeletion() {
* @see field_test_entity_bundle_field_info_alter() * @see field_test_entity_bundle_field_info_alter()
*/ */
protected function doFieldValidationTests() { protected function doFieldValidationTests() {