diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php index c813790..87da84c 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSyncImageTest.php @@ -53,7 +53,7 @@ function setUp() { * Creates the test image field. */ protected function setupTestFields() { - $this->fieldName = 'field_test_et_ui_image'; + $this->fieldName = 'field_sync_image'; $this->cardinality = 3; entity_create('field_entity', array( diff --git a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php index 446ee14..0a56b07c 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php @@ -238,7 +238,7 @@ public function __construct(array $values, $entity_type = 'field_instance') { if (isset($values['field_name']) && isset($values['entity_type']) && !isset($values['field_uuid'])) { $field = field_info_field($values['entity_type'], $values['field_name']); if (!$field) { - throw new FieldException(format_string('Attempt to create an instance of unknown, disabled, or deleted field @field_name', array('@field_name' => $values['field_name']))); + throw new FieldException(format_string('Attempt to create an instance of field @field_name that does not exist on entity type @entity_type.', array('@field_name' => $values['field_name'], '@entity_type' => $values['entity_type']))); } $values['field_uuid'] = $field->uuid; } diff --git a/core/modules/field/lib/Drupal/field/Tests/ActiveTest.php b/core/modules/field/lib/Drupal/field/Tests/ActiveTest.php index d0053ff..7b021e2 100644 --- a/core/modules/field/lib/Drupal/field/Tests/ActiveTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/ActiveTest.php @@ -28,39 +28,28 @@ public static function getInfo() { * Test that fields are properly marked active or inactive. */ function testActive() { - $field_definition = array( - 'name' => 'field_1', + $field_name = 'field_1'; + entity_create('field_entity', array( + 'name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'test_field', - ); - entity_create('field_entity', $field_definition)->save(); - - // Test disabling and enabling the field type module, - $modules = array('field_test'); - $field_name = $field_definition['name']; + ))->save(); - // Read the field. + // Check that the field is correctly found. $field = field_read_field('entity_test', $field_name); - $this->assertTrue($field_definition <= $field, 'The field was properly read.'); - - module_disable($modules, FALSE); + $this->assertFalse(empty($field), 'The field was properly read.'); - $fields = field_read_fields(array('entity_type' => 'entity_test', 'name' => $field_name), array('include_inactive' => TRUE)); - $this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, 'The field is properly read when explicitly fetching inactive fields.'); - - // Re-enable modules one by one, and check that the field is still inactive - // while some modules remain disabled. - while ($modules) { - $field = field_read_field('entity_test', $field_name); - $this->assertTrue(empty($field), format_string('%modules disabled. The field is marked inactive.', array('%modules' => implode(', ', $modules)))); - - $module = array_shift($modules); - module_enable(array($module), FALSE); - } + // Disable the module providing the field type, and check that the field is + // found only if explicitly requesting inactive fields. + module_disable(array('field_test')); + $field = field_read_field('entity_test', $field_name); + $this->assertTrue(empty($field), 'The field is marked inactive when the field type is absent.'); + $field = field_read_field('entity_test', $field_name, array('include_inactive' => TRUE)); + $this->assertFalse(empty($field), 'The field is properly read when explicitly fetching inactive fields.'); - // Check that the field is active again after all modules have been - // enabled. + // Re-enable the module, and check that the field is active again. + module_enable(array('field_test')); $field = field_read_field('entity_test', $field_name); - $this->assertTrue($field_definition <= $field, 'The field was was marked active.'); + $this->assertFalse(empty($field), 'The field was was marked active.'); } } diff --git a/core/modules/file/file.views.inc b/core/modules/file/file.views.inc index 9dd0ce6..cfc7fa3 100644 --- a/core/modules/file/file.views.inc +++ b/core/modules/file/file.views.inc @@ -498,6 +498,7 @@ function file_field_views_data_views_data_alter(&$data, $field, $sql_entity_type 'help' => t('Relate each @entity with a @field set to the file.', array('@entity' => $entity, '@field' => $label)), 'id' => 'entity_reverse', 'field_name' => $field['field_name'], + 'entity_type' => $field['entity_type'], 'field table' => DatabaseStorageController::_fieldTableName($field), 'field field' => $field['field_name'] . '_target_id', 'base' => $entity_info['base_table'], @@ -505,10 +506,6 @@ function file_field_views_data_views_data_alter(&$data, $field, $sql_entity_type 'label' => t('!field_name', array('!field_name' => $field['field_name'])), 'join_extra' => array( 0 => array( - 'field' => 'entity_type', - 'value' => $entity_type, - ), - 1 => array( 'field' => 'deleted', 'value' => 0, 'numeric' => TRUE, diff --git a/core/modules/hal/lib/Drupal/hal/Tests/DenormalizeTest.php b/core/modules/hal/lib/Drupal/hal/Tests/DenormalizeTest.php index e0c8ae1..646b34e 100644 --- a/core/modules/hal/lib/Drupal/hal/Tests/DenormalizeTest.php +++ b/core/modules/hal/lib/Drupal/hal/Tests/DenormalizeTest.php @@ -95,7 +95,7 @@ public function testMarkFieldForDeletion() { ), ); $no_field_denormalized = $this->serializer->denormalize($no_field_data, $this->entityClass, $this->format); - $no_field_value = $no_field_denormalized->field_test_text->getValue(); + $no_field_value = $no_field_denormalized->test_text->getValue(); $empty_field_data = array( '_links' => array( @@ -103,10 +103,10 @@ public function testMarkFieldForDeletion() { 'href' => url('rest/type/entity_test/entity_test', array('absolute' => TRUE)), ), ), - 'field_test_text' => array(), + 'test_text' => array(), ); $empty_field_denormalized = $this->serializer->denormalize($empty_field_data, $this->entityClass, $this->format); - $empty_field_value = $empty_field_denormalized->field_test_text->getValue(); + $empty_field_value = $empty_field_denormalized->test_text->getValue(); $this->assertTrue(!empty($no_field_value) && empty($empty_field_value), 'A field set to an empty array in the data is structured differently than an empty field.'); } @@ -126,13 +126,13 @@ public function testBasicFieldDenormalization() { 'value' => 'e5c9fb96-3acf-4a8d-9417-23de1b6c3311', ), ), - 'field_test_text' => array( + 'test_text' => array( array( 'value' => $this->randomName(), 'format' => 'full_html', ), ), - 'field_translatable_text' => array( + 'translatable_text' => array( array( 'value' => $this->randomName(), 'format' => 'full_html', @@ -156,28 +156,28 @@ public function testBasicFieldDenormalization() { $expected_value_default = array( array ( - 'value' => $data['field_translatable_text'][0]['value'], + 'value' => $data['translatable_text'][0]['value'], 'format' => 'full_html', ), array ( - 'value' => $data['field_translatable_text'][1]['value'], + 'value' => $data['translatable_text'][1]['value'], 'format' => 'filtered_html', ), ); $expected_value_de = array( array ( - 'value' => $data['field_translatable_text'][2]['value'], + 'value' => $data['translatable_text'][2]['value'], 'format' => 'filtered_html', ), array ( - 'value' => $data['field_translatable_text'][3]['value'], + 'value' => $data['translatable_text'][3]['value'], 'format' => 'full_html', ), ); $denormalized = $this->serializer->denormalize($data, $this->entityClass, $this->format); $this->assertEqual($data['uuid'], $denormalized->get('uuid')->getValue(), 'A preset value (e.g. UUID) is overridden by incoming data.'); - $this->assertEqual($data['field_test_text'], $denormalized->get('field_test_text')->getValue(), 'A basic text field is denormalized.'); - $this->assertEqual($expected_value_default, $denormalized->get('field_translatable_text')->getValue(), 'Values in the default language are properly handled for a translatable field.'); - $this->assertEqual($expected_value_de, $denormalized->getTranslation('de')->get('field_translatable_text')->getValue(), 'Values in a translation language are properly handled for a translatable field.'); + $this->assertEqual($data['test_text'], $denormalized->get('test_text')->getValue(), 'A basic text field is denormalized.'); + $this->assertEqual($expected_value_default, $denormalized->get('translatable_text')->getValue(), 'Values in the default language are properly handled for a translatable field.'); + $this->assertEqual($expected_value_de, $denormalized->getTranslation('de')->get('translatable_text')->getValue(), 'Values in a translation language are properly handled for a translatable field.'); } } diff --git a/core/modules/hal/lib/Drupal/hal/Tests/NormalizeTest.php b/core/modules/hal/lib/Drupal/hal/Tests/NormalizeTest.php index 67e64e3..6f559e0 100644 --- a/core/modules/hal/lib/Drupal/hal/Tests/NormalizeTest.php +++ b/core/modules/hal/lib/Drupal/hal/Tests/NormalizeTest.php @@ -24,9 +24,9 @@ public static function getInfo() { * Tests the normalize function. */ public function testNormalize() { - $target_entity_de = entity_create('entity_test', (array('langcode' => 'de', 'field_entity_reference' => NULL))); + $target_entity_de = entity_create('entity_test', (array('langcode' => 'de', 'entity_ref' => NULL))); $target_entity_de->save(); - $target_entity_en = entity_create('entity_test', (array('langcode' => 'en', 'field_entity_reference' => NULL))); + $target_entity_en = entity_create('entity_test', (array('langcode' => 'en', 'entity_ref' => NULL))); $target_entity_en->save(); // Create a German entity. @@ -34,18 +34,18 @@ public function testNormalize() { 'langcode' => 'de', 'name' => $this->randomName(), 'user_id' => 1, - 'field_test_text' => array( + 'test_text' => array( 'value' => $this->randomName(), 'format' => 'full_html', ), - 'field_entity_reference' => array( + 'entity_ref' => array( 'target_id' => $target_entity_de->id(), ), ); // Array of translated values. $translation_values = array( 'name' => $this->randomName(), - 'field_entity_reference' => array( + 'entity_ref' => array( 'target_id' => $target_entity_en->id(), ) ); @@ -54,11 +54,11 @@ public function testNormalize() { $entity->save(); // Add an English value for name and entity reference properties. $entity->getTranslation('en')->set('name', array(0 => array('value' => $translation_values['name']))); - $entity->getTranslation('en')->set('field_entity_reference', array(0 => $translation_values['field_entity_reference'])); + $entity->getTranslation('en')->set('entity_ref', array(0 => $translation_values['entity_ref'])); $entity->save(); $type_uri = url('rest/type/entity_test/entity_test', array('absolute' => TRUE)); - $relation_uri = url('rest/relation/entity_test/entity_test/field_test_entity_reference', array('absolute' => TRUE)); + $relation_uri = url('rest/relation/entity_test/entity_test/entity_ref', array('absolute' => TRUE)); $expected_array = array( '_links' => array( @@ -142,10 +142,10 @@ public function testNormalize() { 'lang' => 'en', ), ), - 'field_test_text' => array( + 'test_text' => array( array( - 'value' => $values['field_test_text']['value'], - 'format' => $values['field_test_text']['format'], + 'value' => $values['test_text']['value'], + 'format' => $values['test_text']['format'], ), ), ); @@ -157,7 +157,7 @@ public function testNormalize() { $this->assertFalse(isset($normalized['id']), 'Internal id is not exposed.'); $this->assertEqual($normalized['uuid'], $expected_array['uuid'], 'Non-translatable fields is normalized.'); $this->assertEqual($normalized['name'], $expected_array['name'], 'Translatable field with multiple language values is normalized.'); - $this->assertEqual($normalized['field_test_text'], $expected_array['field_test_text'], 'Field with properties is normalized.'); + $this->assertEqual($normalized['test_text'], $expected_array['test_text'], 'Field with properties is normalized.'); $this->assertEqual($normalized['_embedded'][$relation_uri], $expected_array['_embedded'][$relation_uri], 'Entity reference field is normalized.'); $this->assertEqual($normalized['_links'][$relation_uri], $expected_array['_links'][$relation_uri], 'Links are added for entity reference field.'); } diff --git a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php index a14fc69..243e692 100644 --- a/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php +++ b/core/modules/hal/lib/Drupal/hal/Tests/NormalizerTestBase.php @@ -78,27 +78,27 @@ function setUp() { // Create the test text field. entity_create('field_entity', array( - 'name' => 'field_test_text', + 'name' => 'test_text', 'entity_type' => 'entity_test', 'type' => 'text', 'translatable' => FALSE, ))->save(); entity_create('field_instance', array( 'entity_type' => 'entity_test', - 'field_name' => 'field_test_text', + 'field_name' => 'test_text', 'bundle' => 'entity_test', ))->save(); // Create the test translatable field. entity_create('field_entity', array( - 'name' => 'field_translatable_text', + 'name' => 'translatable_text', 'entity_type' => 'entity_test', 'type' => 'text', 'translatable' => TRUE, ))->save(); entity_create('field_instance', array( 'entity_type' => 'entity_test', - 'field_name' => 'field_translatable_text', + 'field_name' => 'translatable_text', 'bundle' => 'entity_test', ))->save(); @@ -108,13 +108,13 @@ function setUp() { 'settings' => array( 'target_type' => 'entity_test', ), - 'name' => 'field_entity_reference', + 'name' => 'entity_ref', 'entity_type' => 'entity_test', 'type' => 'entity_reference', ))->save(); entity_create('field_instance', array( 'entity_type' => 'entity_test', - 'field_name' => 'field_entity_reference', + 'field_name' => 'entity_ref', 'bundle' => 'entity_test', ))->save(); diff --git a/core/modules/image/image.views.inc b/core/modules/image/image.views.inc index 2d244ff..cfb4d63 100644 --- a/core/modules/image/image.views.inc +++ b/core/modules/image/image.views.inc @@ -52,6 +52,7 @@ function image_field_views_data_views_data_alter(&$data, $field, $sql_entity_typ 'help' => t('Relate each @entity with a @field set to the image.', array('@entity' => $entity, '@field' => $label)), 'id' => 'entity_reverse', 'field_name' => $field['field_name'], + 'entity_type' => $field['entity_type'], 'field table' => DatabaseStorageController::_fieldTableName($field), 'field field' => $field['field_name'] . '_target_id', 'base' => $entity_info['base_table'], @@ -59,10 +60,6 @@ function image_field_views_data_views_data_alter(&$data, $field, $sql_entity_typ 'label' => t('!field_name', array('!field_name' => $field['field_name'])), 'join_extra' => array( 0 => array( - 'field' => 'entity_type', - 'value' => $entity_type, - ), - 1 => array( 'field' => 'deleted', 'value' => 0, 'numeric' => TRUE, diff --git a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module index f5a5ede..5b54e13 100644 --- a/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module +++ b/core/modules/node/tests/modules/node_access_test_language/node_access_test_language.module @@ -62,7 +62,7 @@ function node_access_test_language_enable() { $field_private->save(); entity_create('field_instance', array( - 'field_name' => $field_private->id(), + 'field_name' => $field_private->name, 'entity_type' => 'node', 'bundle' => 'page', 'widget' => array( diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php index 772914e..d095804 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntityResolverTest.php @@ -38,7 +38,7 @@ protected function setUp() { 'settings' => array( 'target_type' => 'entity_test_mulrev', ), - 'name' => 'field_entity_reference', + 'name' => 'entity_ref', 'entity_type' => 'entity_test_mulrev', 'type' => 'entity_reference', ))->save(); @@ -46,7 +46,7 @@ protected function setUp() { // Create the test field instance. entity_create('field_instance', array( 'entity_type' => 'entity_test_mulrev', - 'field_name' => 'field_entity_reference', + 'field_name' => 'entity_ref', 'bundle' => 'entity_test_mulrev', ))->save(); } @@ -58,10 +58,10 @@ function testUuidEntityResolver() { // Create an entity to get the UUID from. $entity = entity_create('entity_test_mulrev', array('type' => 'entity_test_mulrev')); $entity->set('name', 'foobar'); - $entity->set('field_entity_reference', array(array('target_id' => 1))); + $entity->set('entity_ref', array(array('target_id' => 1))); $entity->save(); - $field_uri = url('rest/relation/entity_test_mulrev/entity_test_mulrev/field_test_entity_reference', array('absolute' => TRUE)); + $field_uri = url('rest/relation/entity_test_mulrev/entity_test_mulrev/entity_ref', array('absolute' => TRUE)); $data = array( '_links' => array( @@ -91,7 +91,7 @@ function testUuidEntityResolver() { ); $denormalized = $this->container->get('serializer')->denormalize($data, 'Drupal\entity_test\Plugin\Core\Entity\EntityTestMulRev', $this->format); - $field_value = $denormalized->get('field_entity_reference')->getValue(); + $field_value = $denormalized->get('entity_ref')->getValue(); $this->assertEqual($field_value[0]['target_id'], 1, 'Entity reference resolved using UUID.'); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php index 4886c2b..e1b0ea7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryTest.php @@ -405,12 +405,19 @@ protected function testTableSort() { } /** - * Test entity count query. + * Test that count queries are separated across entity types. */ protected function testCount() { - // Attach the existing 'figures' field to a second entity type so that we - // can test whether cross entity type fields produce the correct query. + // Create a field with the same name in a different entity type. $field_name = $this->figures; + $field = entity_create('field_entity', array( + 'name' => $field_name, + 'entity_type' => 'entity_test', + 'type' => 'shape', + 'cardinality' => 2, + 'translatable' => TRUE, + )); + $field->save(); $bundle = $this->randomName(); entity_create('field_instance', array( 'field_name' => $field_name, @@ -425,6 +432,7 @@ protected function testCount() { $entity->enforceIsNew(); $entity->setNewRevision(); $entity->save(); + // As the single entity of this type we just saved does not have a value // in the color field, the result should be 0. $count = $this->factory->get('entity_test') diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index 7adfda3..cd72962 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -50,7 +50,7 @@ function setUp() { $this->state->set('entity_test.translation', TRUE); // Create a translatable test field. - $this->field_name = drupal_strtolower($this->randomName() . '_field_name'); + $this->field_name = drupal_strtolower($this->randomName(3) . '_field_name'); // Create instance in all entity variations. foreach (entity_test_entity_types() as $entity_type) { diff --git a/core/modules/taxonomy/taxonomy.views.inc b/core/modules/taxonomy/taxonomy.views.inc index 01fbba2..738bfdd 100644 --- a/core/modules/taxonomy/taxonomy.views.inc +++ b/core/modules/taxonomy/taxonomy.views.inc @@ -380,6 +380,7 @@ function taxonomy_field_views_data_views_data_alter(&$data, $field, $sql_entity_ 'help' => t('Relate each @entity with a @field set to the term.', array('@entity' => $entity, '@field' => $label)), 'id' => 'entity_reverse', 'field_name' => $field['field_name'], + 'entity_type' => $field['entity_type'], 'field table' => DatabaseStorageController::_fieldTableName($field), 'field field' => $field['field_name'] . '_target_id', 'base' => $entity_info['base_table'], @@ -387,10 +388,6 @@ function taxonomy_field_views_data_views_data_alter(&$data, $field, $sql_entity_ 'label' => t('!field_name', array('!field_name' => $field['field_name'])), 'join_extra' => array( 0 => array( - 'field' => 'entity_type', - 'value' => $entity_type, - ), - 1 => array( 'field' => 'deleted', 'value' => 0, 'numeric' => TRUE,