Commit eebf624a authored by alexpott's avatar alexpott

Issue #2030633 by hussainweb, Mile23, carsonevans, czigor, Berdir,...

Issue #2030633 by hussainweb, Mile23, carsonevans, czigor, Berdir, fernando_calsa, Geijutsuka, amitgoyal, Jānis Bebrītis, undertext: Expand FieldStorageConfig with methods
parent 6eb18e4f
......@@ -50,7 +50,7 @@ function setUp() {
// Make the body field translatable. The info is already translatable by
// definition.
$field_storage = FieldStorageConfig::loadByName('block_content', 'body');
$field_storage->translatable = TRUE;
$field_storage->setTranslatable(TRUE);
$field_storage->save();
// Set up block_content infos.
......
......@@ -97,7 +97,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$caption = '';
foreach (array_keys($this->commentManager->getFields($entity_type)) as $field_name) {
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
if (($field_storage = FieldStorageConfig::loadByName($entity_type, $field_name)) && $field_storage->getSetting('comment_type') == $this->entity->id() && !$field_storage->deleted) {
if (($field_storage = FieldStorageConfig::loadByName($entity_type, $field_name)) && $field_storage->getSetting('comment_type') == $this->entity->id() && !$field_storage->isDeleted()) {
$caption .= '<p>' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', array(
'%label' => $this->entity->label(),
'%field' => $field_storage->label(),
......
......@@ -73,7 +73,7 @@ protected function setUp() {
// Make comment body translatable.
$field_storage = FieldStorageConfig::loadByName('comment', 'comment_body');
$field_storage->translatable = TRUE;
$field_storage->setTranslatable(TRUE);
$field_storage->save();
$this->assertTrue($field_storage->isTranslatable(), 'Comment body is translatable.');
}
......
......@@ -143,7 +143,7 @@ public function testExportImport() {
}
$field_storages = FieldStorageConfig::loadMultiple();
foreach ($field_storages as $field_storage) {
if ($field_storage->field_name == $this->fieldName) {
if ($field_storage->getName() == $this->fieldName) {
$field_storage->delete();
}
}
......
......@@ -95,7 +95,7 @@ protected function setUp() {
* Tests date field functionality.
*/
function testDateField() {
$field_name = $this->fieldStorage->field_name;
$field_name = $this->fieldStorage->getName();
// Display creation form.
$this->drupalGet('entity_test/add');
......@@ -163,7 +163,7 @@ function testDateField() {
function testDatetimeField() {
$field_name = $this->fieldStorage->getName();
// Change the field to a datetime field.
$this->fieldStorage->settings['datetime_type'] = 'datetime';
$this->fieldStorage->setSetting('datetime_type', 'datetime');
$this->fieldStorage->save();
// Display creation form.
......@@ -229,7 +229,7 @@ function testDatetimeField() {
function testDatelistWidget() {
$field_name = $this->fieldStorage->getName();
// Change the field to a datetime field.
$this->fieldStorage->settings['datetime_type'] = 'datetime';
$this->fieldStorage->setSetting('datetime_type', 'datetime');
$this->fieldStorage->save();
// Change the widget to a datelist widget.
......@@ -393,7 +393,7 @@ function testDefaultValue() {
function testInvalidField() {
// Change the field to a datetime field.
$this->fieldStorage->settings['datetime_type'] = 'datetime';
$this->fieldStorage->setSetting('datetime_type', 'datetime');
$this->fieldStorage->save();
$field_name = $this->fieldStorage->getName();
......
......@@ -145,7 +145,7 @@ public function testEditorSelection() {
$this->assertEqual('editor', $this->getSelectedEditor($entity->id(), $this->fieldName), "With cardinality 1, and the full_html text format, the 'editor' editor is selected.");
// Editor selection with text processing, cardinality >1
$this->fields->field_textarea_field_storage->cardinality = 2;
$this->fields->field_textarea_field_storage->setCardinality(2);
$this->fields->field_textarea_field_storage->save();
$this->assertEqual('form', $this->getSelectedEditor($entity->id(), $this->fieldName), "With cardinality >1, and both items using the full_html text format, the 'form' editor is selected.");
}
......
......@@ -69,7 +69,7 @@ function entity_reference_field_widget_info_alter(&$info) {
* Reset the instance handler settings, when the target type is changed.
*/
function entity_reference_field_storage_config_update(FieldStorageConfigInterface $field_storage) {
if ($field_storage->type != 'entity_reference') {
if ($field_storage->getType() != 'entity_reference') {
// Only act on entity reference fields.
return;
}
......
......@@ -81,7 +81,7 @@ function hook_field_storage_config_update_forbid(\Drupal\field\FieldStorageConfi
$allowed_values = $field_storage->getSetting('allowed_values');
$prior_allowed_values = $prior_field_storage->getSetting('allowed_values');
$lost_keys = array_keys(array_diff_key($prior_allowed_values,$allowed_values));
if (_options_values_in_use($field_storage->entity_type, $field_storage->getName(), $lost_keys)) {
if (_options_values_in_use($field_storage->getTargetEntityTypeId(), $field_storage->getName(), $lost_keys)) {
throw new \Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array('@field_name' => $field_storage->getName())));
}
}
......
......@@ -153,7 +153,7 @@ function field_system_info_alter(&$info, Extension $file, $type) {
// remains no actual, non-deleted fields)
$non_deleted = FALSE;
foreach ($field_storages as $field_storage) {
if (empty($field_storage->deleted)) {
if (!$field_storage->isDeleted()) {
$non_deleted = TRUE;
break;
}
......
......@@ -84,7 +84,7 @@ function field_purge_batch($batch_size, $field_storage_uuid = NULL) {
$info = \Drupal::entityManager()->getDefinitions();
foreach ($fields as $field) {
$entity_type = $field->entity_type;
$entity_type = $field->getTargetEntityTypeId();
// We cannot purge anything if the entity type is unknown (e.g. the
// providing module was uninstalled).
......@@ -117,7 +117,7 @@ function field_purge_batch($batch_size, $field_storage_uuid = NULL) {
// We cannot purge anything if the entity type is unknown (e.g. the
// providing module was uninstalled).
// @todo Revisit after https://drupal.org/node/2080823.
if (!isset($info[$field_storage->entity_type])) {
if (!isset($info[$field_storage->getTargetEntityTypeId()])) {
continue;
}
......@@ -170,7 +170,7 @@ function field_purge_field_storage(FieldStorageConfigInterface $field_storage) {
$state->set('field.storage.deleted', $deleted_storages);
// Notify the storage layer.
\Drupal::entityManager()->getStorage($field_storage->entity_type)->finalizePurge($field_storage);
\Drupal::entityManager()->getStorage($field_storage->getTargetEntityTypeId())->finalizePurge($field_storage);
// Invoke external hooks after the cache is cleared for API consistency.
\Drupal::moduleHandler()->invokeAll('field_purge_field_storage', array($field_storage));
......
......@@ -40,7 +40,7 @@ public static function process(array &$context, ConfigImporter $config_importer)
$context['sandbox']['field']['current_storage_id'] = $field_storage->id();
// If the storage has not been deleted yet we need to do that. This is the
// case when the storage deletion is staged.
if (!$field_storage->deleted) {
if (!$field_storage->isDeleted()) {
$field_storage->delete();
}
}
......@@ -138,9 +138,10 @@ public static function getFieldStoragesToPurge(array $extensions, array $deletes
}
// Gather deleted fields from modules that are being uninstalled.
/** @var \Drupal\field\FieldStorageConfigInterface[] $field_storages */
$field_storages = entity_load_multiple_by_properties('field_storage_config', array('deleted' => TRUE, 'include_deleted' => TRUE));
foreach ($field_storages as $field_storage) {
if (!in_array($field_storage->module, $providers)) {
if (!in_array($field_storage->getTypeProvider(), $providers)) {
$storages_to_delete[$field_storage->id()] = $field_storage;
}
}
......
......@@ -141,7 +141,7 @@ public function preSave(EntityStorageInterface $storage) {
// Filter out unknown settings and make sure all settings are present, so
// that a complete field definition is passed to the various hooks and
// written to config.
$default_settings = $field_type_manager->getDefaultFieldSettings($storage_definition->type);
$default_settings = $field_type_manager->getDefaultFieldSettings($storage_definition->getType());
$this->settings = array_intersect_key($this->settings, $default_settings) + $default_settings;
if ($this->isNew()) {
......
......@@ -51,7 +51,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
*
* @var string
*/
public $id;
protected $id;
/**
* The field name.
......@@ -64,14 +64,14 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
*
* @var string
*/
public $field_name;
protected $field_name;
/**
* The name of the entity type the field can be attached to.
*
* @var string
*/
public $entity_type;
protected $entity_type;
/**
* The field type.
......@@ -80,14 +80,14 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
*
* @var string
*/
public $type;
protected $type;
/**
* The name of the module that provides the field type.
*
* @var string
*/
public $module;
protected $module;
/**
* Field-type specific settings.
......@@ -97,7 +97,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
*
* @var array
*/
public $settings = array();
protected $settings = [];
/**
* The field cardinality.
......@@ -108,7 +108,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
*
* @var int
*/
public $cardinality = 1;
protected $cardinality = 1;
/**
* Flag indicating whether the field is translatable.
......@@ -117,7 +117,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
*
* @var bool
*/
public $translatable = TRUE;
protected $translatable = TRUE;
/**
* Flag indicating whether the field is available for editing.
......@@ -131,7 +131,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
*
* @var bool
*/
public $locked = FALSE;
protected $locked = FALSE;
/**
* Flag indicating whether the field storage should be deleted when orphaned.
......@@ -164,7 +164,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
*
* @var array
*/
public $indexes = array();
protected $indexes = [];
/**
* Flag indicating whether the field is deleted.
......@@ -179,7 +179,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
*
* @var bool
*/
public $deleted = FALSE;
protected $deleted = FALSE;
/**
* The field schema.
......@@ -238,7 +238,7 @@ public function __construct(array $values, $entity_type = 'field_storage_config'
* {@inheritdoc}
*/
public function id() {
return $this->entity_type . '.' . $this->field_name;
return $this->getTargetEntityTypeId() . '.' . $this->getName();
}
/**
......@@ -288,25 +288,25 @@ protected function preSaveNew(EntityStorageInterface $storage) {
// Field name cannot be longer than FieldStorageConfig::NAME_MAX_LENGTH characters.
// We use Unicode::strlen() because the DB layer assumes that column widths
// are given in characters rather than bytes.
if (Unicode::strlen($this->field_name) > static::NAME_MAX_LENGTH) {
if (Unicode::strlen($this->getName()) > static::NAME_MAX_LENGTH) {
throw new FieldException(String::format(
'Attempt to create a field storage with an name longer than @max characters: %name', array(
'@max' => static::NAME_MAX_LENGTH,
'%name' => $this->field_name,
'%name' => $this->getName(),
)
));
}
// Disallow reserved field names.
$disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->entity_type));
if (in_array($this->field_name, $disallowed_field_names)) {
throw new FieldException(String::format('Attempt to create field storage %name which is reserved by entity type %type.', array('%name' => $this->field_name, '%type' => $this->entity_type)));
$disallowed_field_names = array_keys($entity_manager->getBaseFieldDefinitions($this->getTargetEntityTypeId()));
if (in_array($this->getName(), $disallowed_field_names)) {
throw new FieldException(String::format('Attempt to create field storage %name which is reserved by entity type %type.', array('%name' => $this->getName(), '%type' => $this->getTargetEntityTypeId())));
}
// Check that the field type is known.
$field_type = $field_type_manager->getDefinition($this->type, FALSE);
$field_type = $field_type_manager->getDefinition($this->getType(), FALSE);
if (!$field_type) {
throw new FieldException(String::format('Attempt to create a field storage of unknown type %type.', array('%type' => $this->type)));
throw new FieldException(String::format('Attempt to create a field storage of unknown type %type.', array('%type' => $this->getType())));
}
$this->module = $field_type['provider'];
......@@ -320,7 +320,7 @@ protected function preSaveNew(EntityStorageInterface $storage) {
public function calculateDependencies() {
parent::calculateDependencies();
// Ensure the field is dependent on the providing module.
$this->addDependency('module', $this->module);
$this->addDependency('module', $this->getTypeProvider());
// Ensure the field is dependent on the provider of the entity type.
$entity_type = \Drupal::entityManager()->getDefinition($this->entity_type);
$this->addDependency('module', $entity_type->getProvider());
......@@ -338,10 +338,10 @@ protected function preSaveUpdated(EntityStorageInterface $storage) {
$entity_manager = \Drupal::entityManager();
// Some updates are always disallowed.
if ($this->type != $this->original->type) {
if ($this->getType() != $this->original->getType()) {
throw new FieldException("Cannot change the field type for an existing field storage.");
}
if ($this->entity_type != $this->original->entity_type) {
if ($this->getTargetEntityTypeId() != $this->original->getTargetEntityTypeId()) {
throw new FieldException("Cannot change the entity type for an existing field storage.");
}
......@@ -383,7 +383,9 @@ public static function preDelete(EntityStorageInterface $storage, array $field_s
foreach ($field_storages as $field_storage) {
if (!$field_storage->deleted) {
foreach ($field_storage->getBundles() as $bundle) {
$field_ids[] = "{$field_storage->entity_type}.$bundle.{$field_storage->field_name}";
$entity_type = $field_storage->getTargetEntityTypeId();
$field_name = $field_storage->getName();
$field_ids[] = "{$entity_type}.$bundle.{$field_name}";
}
}
}
......@@ -481,10 +483,10 @@ public function getColumns() {
* {@inheritdoc}
*/
public function getBundles() {
if (empty($this->deleted)) {
if (!$this->isDeleted()) {
$map = \Drupal::entityManager()->getFieldMap();
if (isset($map[$this->entity_type][$this->field_name]['bundles'])) {
return $map[$this->entity_type][$this->field_name]['bundles'];
if (isset($map[$this->getTargetEntityTypeId()][$this->getName()]['bundles'])) {
return $map[$this->getTargetEntityTypeId()][$this->getName()]['bundles'];
}
}
return array();
......@@ -497,6 +499,20 @@ public function getName() {
return $this->field_name;
}
/**
* {@inheritdoc}
*/
public function isDeleted() {
return $this->deleted;
}
/**
* {@inheritdoc}
*/
public function getTypeProvider() {
return $this->module;
}
/**
* {@inheritdoc}
*/
......@@ -514,7 +530,7 @@ public function getSettings() {
// within $this.
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
$settings = $field_type_manager->getDefaultStorageSettings($this->type);
$settings = $field_type_manager->getDefaultStorageSettings($this->getType());
return $this->settings + $settings;
}
......@@ -537,6 +553,22 @@ public function getSetting($setting_name) {
}
}
/**
* {@inheritdoc}
*/
public function setSetting($setting_name, $value) {
$this->settings[$setting_name] = $value;
return $this;
}
/**
* {@inheritdoc}
*/
public function setSettings(array $settings) {
$this->settings = $settings;
return $this;
}
/**
* {@inheritdoc}
*/
......@@ -588,6 +620,14 @@ public function getCardinality() {
return $this->cardinality;
}
/**
* {@inheritdoc}
*/
public function setCardinality($cardinality) {
$this->cardinality = $cardinality;
return $this;
}
/**
* {@inheritdoc}
*/
......@@ -618,6 +658,14 @@ public function isLocked() {
return $this->locked;
}
/**
* {@inheritdoc}
*/
public function setLocked($locked) {
$this->locked = $locked;
return $this;
}
/**
* {@inheritdoc}
*/
......@@ -750,4 +798,19 @@ public function isDeletable() {
return !$this->deleted && !$this->persist_with_no_fields && count($this->getBundles()) == 0;
}
/**
* {@inheritdoc}
*/
public function getIndexes() {
return $this->indexes;
}
/**
* {@inheritdoc}
*/
public function setIndexes(array $indexes) {
$this->indexes = $indexes;
return $this;
}
}
......@@ -15,6 +15,22 @@
*/
interface FieldStorageConfigInterface extends ConfigEntityInterface, FieldStorageDefinitionInterface {
/**
* Returns the field type.
*
* @return string
* The field type, i.e. the id of a field type plugin. For example 'text'.
*/
public function getType();
/**
* Returns the name of the module providing the field type.
*
* @return string
* The name of the module that provides the field type.
*/
public function getTypeProvider();
/**
* Returns the list of bundles where the field storage has fields.
*
......@@ -24,12 +40,12 @@
public function getBundles();
/**
* Returns whether the field storage is locked or not.
* Returns whether the field is deleted or not.
*
* @return bool
* TRUE if the field storage is locked.
* TRUE if the field is deleted.
*/
public function isLocked();
public function isDeleted();
/**
* Checks if the field storage can be deleted.
......@@ -39,4 +55,82 @@ public function isLocked();
*/
public function isDeletable();
/**
* Returns whether the field storage is locked or not.
*
* @return bool
* TRUE if the field storage is locked.
*/
public function isLocked();
/**
* Sets the locked flag.
*
* @param bool $locked
* Sets value of locked flag.
*
* @return $this
*/
public function setLocked($locked);
/**
* Sets the maximum number of items allowed for the field.
*
* @param int $cardinality
* The cardinality value.
*
* @return $this
*/
public function setCardinality($cardinality);
/**
* Sets the value for a field setting by name.
*
* @param string $setting_name
* The name of the setting.
* @param mixed $value
* The value of the setting.
*
* @return $this
*/
public function setSetting($setting_name, $value);
/**
* Sets field settings (overwrites existing settings).
*
* @param array $settings
* The array of field settings.
*
* @return $this
*/
public function setSettings(array $settings);
/**
* Sets whether the field is translatable.
*
* @param bool $translatable
* Whether the field is translatable.
*
* @return $this
*/
public function setTranslatable($translatable);
/**
* Returns the custom storage indexes for the field data storage.
*
* @return array
* An array of custom indexes.
*/
public function getIndexes();
/**
* Sets the custom storage indexes for the field data storage..
*
* @param array $indexes
* The array of custom indexes.
*
* @return $this
*/
public function setIndexes(array $indexes);
}
......@@ -104,6 +104,7 @@ public function loadByProperties(array $conditions = array()) {
$include_deleted = isset($conditions['include_deleted']) ? $conditions['include_deleted'] : FALSE;
unset($conditions['include_deleted']);
/** @var \Drupal\field\FieldStorageConfigInterface[] $storages */
$storages = array();
// Get field storages living in configuration. If we are explicitly looking
......@@ -134,16 +135,7 @@ public function loadByProperties(array $conditions = array()) {
foreach ($storages as $field) {
foreach ($conditions as $key => $value) {
// Extract the actual value against which the condition is checked.
switch ($key) {
case 'uuid';
$checked_value = $field->uuid();
break;
default:
$checked_value = $field->$key;
break;
}
$checked_value = $field->get($key);
// Skip to the next field as soon as one condition does not match.
if ($checked_value != $value) {
continue 2;
......
......@@ -314,7 +314,7 @@ function testPurgeFieldStorage() {
$this->assertEqual(count($fields), 0, 'The field is purged.');
// The field storage still exists, not deleted.
$storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
$this->assertTrue(isset($storages[$field_storage->uuid()]) && !$storages[$field_storage->uuid()]->deleted, 'The field storage exists and is not deleted');
$this->assertTrue(isset($storages[$field_storage->uuid()]) && !$storages[$field_storage->uuid()]->isDeleted(), 'The field storage exists and is not deleted');
// Delete the second field.
$bundle = next($this->bundles);
......@@ -341,7 +341,7 @@ function testPurgeFieldStorage() {
$fields = entity_load_multiple_by_properties('field_config', array('uuid' => $field->uuid(), 'include_deleted' => TRUE));
$this->assertTrue(isset($fields[$field->uuid()]) && $fields[$field->uuid()]->deleted, 'The field exists and is deleted');
$storages = entity_load_multiple_by_properties('field_storage_config', array('uuid' => $field_storage->uuid(), 'include_deleted' => TRUE));
$this->assertTrue(isset($storages[$field_storage->uuid()]) && $storages[$field_storage->uuid()]->deleted, 'The field storage exists and is deleted');
$this->assertTrue(isset($storages[$field_storage->uuid()]) && $storages[$field_storage->uuid()]->isDeleted(), 'The field storage exists and is deleted');
// Purge again to purge the field and the storage.
field_purge_batch(0);
......
......@@ -244,7 +244,7 @@ public function testLabelFormatter() {
// \Drupal\Core\Entity\EntityInterface::urlInfo() will throw an exception
// and the label formatter will output only the label instead of a link.
$field_storage_config = FieldStorageConfig::loadByName($this->entityType, $this->fieldName);
$field_storage_config->settings['target_type'] = 'entity_test_label';
$field_storage_config->setSetting('target_type', 'entity_test_label');
$field_storage_config->save();
$referenced_entity_with_no_link_template = entity_create('entity_test_label', array(
......
......@@ -207,10 +207,10 @@ function testDeleteFieldCrossDeletion() {
entity_create('field_config', $this->fieldDefinition)->save();
entity_create('field_config', $field_definition_2)->save();
$field_storage->delete();
$this->assertFalse(FieldConfig::loadByName('entity_test', $this->fieldDefinition['bundle'], $field_storage->field_name));
$this->assertFalse(FieldConfig::loadByName('entity_test', $field_definition_2['bundle'], $field_storage->field_name));
$this->assertFalse(FieldConfig::loadByName('entity_test', $this->fieldDefinition['bundle'], $field_storage->getName()));
$this->assertFalse(FieldConfig::loadByName('entity_test', $field_definition_2['bundle'], $field_storage->getName()));
// Chack that deletion of the last field deletes the storage.
// Check that deletion of the last field deletes the storage.
$field_storage = entity_create('field_storage_config', $this->fieldStorageDefinition);
$field_storage->save();
$field = entity_create('field_config', $this->fieldDefinition);
......@@ -218,9 +218,9 @@ function testDeleteFieldCrossDeletion() {
$field_2 = entity_create('field_config', $field_definition_2);
$field_2->save();
$field->delete();
$this->assertTrue(FieldStorageConfig::loadByName('entity_test', $field_storage->field_name));
$this->assertTrue(FieldStorageConfig::loadByName('entity_test', $field_storage->getName()));
$field_2->delete();
$this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->field_name));
$this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->getName()));
// Check that deletion of all fields using a storage simultaneously deletes
// the storage.
......@@ -231,7 +231,7 @@ function testDeleteFieldCrossDeletion() {
$field_2 = entity_create('field_config', $field_definition_2);
$field_2->save();
$this->container->get('entity.manager')->getStorage('field_config')->delete(array($field, $field_2));
$this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->field_name));
$this->assertFalse(FieldStorageConfig::loadByName('entity_test', $field_storage->getName()));
}
/**
......
......@@ -305,13 +305,13 @@ function testDelete() {
// Test that the first field is not deleted, and then delete it.
$field_storage = current(entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['field_name'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($field_storage) && empty($field_storage->deleted), 'A new storage is not marked for deletion.');
$this->assertTrue(!empty($field_storage) && !$field_storage->isDeleted(), 'A new storage is not marked for deletion.');
FieldStorageConfig::loadByName('entity_test', $field_storage_definition['field_name'])->delete();
// Make sure that the field is marked as deleted when it is specifically
// loaded.
$field_storage = current(entity_load_multiple_by_properties('field_storage_config', array('field_name' => $field_storage_definition['field_name'], 'include_deleted' => TRUE)));
$this->assertTrue(!empty($field_storage->deleted), 'A deleted storage is marked for deletion.');
$this->assertTrue($field_storage->isDeleted(), 'A deleted storage is marked for deletion.');
// Make sure that this field is marked as deleted when it is
// specifically loaded.
......@@ -328,7 +328,7 @@ function testDelete() {
// Make sure the other field and its storage are not deleted.
$another_field_storage = FieldStorageConfig::load('entity_test.' . $another_field_storage_definition['field_name']);
$this->assertTrue(!empty($another_field_storage) && empty($another_field_storage->deleted), 'A non-deleted storage is not marked for deletion.');
$this->assertTrue(!empty($another_field_storage) && !$another_field_storage->isDeleted(), 'A non-deleted storage is not marked for deletion.');
$another_field = FieldConfig::load('entity_test.' . $another_field_definition['bundle'] . '.' . $another_field_definition['field_name']);
$this->assertTrue(!empty($another_field) && empty($another_field->deleted), 'A field whose storage was not deleted is not marked for deletion.');
......@@ -337,7 +337,7 @@ function testDelete() {
entity_create('field_storage_config', $field_storage_definition)->save();
entity_create('field_config', $field_definition)->save();