security update for context link entity_reference
This commit is contained in:
@@ -68,7 +68,7 @@ class EntityReferenceAdminTestCase extends DrupalWebTestCase {
|
||||
'fields[_add_new_field][type]' => 'entityreference',
|
||||
'fields[_add_new_field][widget_type]' => 'entityreference_autocomplete',
|
||||
), t('Save'));
|
||||
return;
|
||||
|
||||
// Node should be selected by default.
|
||||
$this->assertFieldByName('field[settings][target_type]', 'node');
|
||||
// The base handler should be selected by default.
|
||||
|
||||
+16
-1
@@ -194,6 +194,21 @@ class EntityReferenceHandlersTestCase extends DrupalWebTestCase {
|
||||
),
|
||||
);
|
||||
$this->assertReferencable($field, $referencable_tests, 'Node handler (admin)');
|
||||
|
||||
// Verify autocomplete input validation.
|
||||
$handler = entityreference_get_selection_handler($field);
|
||||
$element = array(
|
||||
'#parents' => array('element_name'),
|
||||
);
|
||||
$form_state = array();
|
||||
$form = array();
|
||||
$value = $handler->validateAutocompleteInput($nodes['published1']->title, $element, $form_state, $form);
|
||||
$this->assertEqual($value, $nodes['published1']->nid);
|
||||
|
||||
$invalid_input = $this->randomName();
|
||||
$value = $handler->validateAutocompleteInput($invalid_input, $element, $form_state, $form);
|
||||
$this->assertNull($value);
|
||||
$this->assertEqual(form_get_error($element), t('There are no entities matching "%value"', array('%value' => $invalid_input)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +271,7 @@ class EntityReferenceHandlersTestCase extends DrupalWebTestCase {
|
||||
),
|
||||
'result' => array(
|
||||
'user' => array(
|
||||
$users['admin']->uid => '- Restricted access -',
|
||||
$users['admin']->uid => ENTITYREFERENCE_DENIED,
|
||||
$users['non_admin']->uid => $user_labels['non_admin'],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -112,4 +112,52 @@ class EntityReferenceTaxonomyTestCase extends DrupalWebTestCase {
|
||||
$this->assertFalse(taxonomy_select_nodes(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a second ER field from node/article to taxonomy.
|
||||
*
|
||||
* This should not cause {taxonomy_index} to receive duplicate entries.
|
||||
*/
|
||||
protected function setupForIndexDuplicates() {
|
||||
// Create an entity reference field.
|
||||
$field = array(
|
||||
'entity_types' => array('node'),
|
||||
'settings' => array(
|
||||
'handler' => 'base',
|
||||
'target_type' => 'taxonomy_term',
|
||||
'handler_settings' => array(
|
||||
'target_bundles' => array(),
|
||||
),
|
||||
),
|
||||
'field_name' => 'field_entityreference_term2',
|
||||
'type' => 'entityreference',
|
||||
);
|
||||
$field = field_create_field($field);
|
||||
$instance = array(
|
||||
'field_name' => 'field_entityreference_term2',
|
||||
'bundle' => 'article',
|
||||
'entity_type' => 'node',
|
||||
);
|
||||
|
||||
// Enable the taxonomy-index behavior.
|
||||
$instance['settings']['behaviors']['taxonomy-index']['status'] = TRUE;
|
||||
field_create_instance($instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure the index only contains one entry for a given node->term
|
||||
* reference, even when multiple ER fields link from the node bundle to terms.
|
||||
*/
|
||||
public function testIndexDuplicates() {
|
||||
// Extra setup for this test: add another ER field on this content type.
|
||||
$this->setupForIndexDuplicates();
|
||||
|
||||
// Assert node insert with reference to term in first field.
|
||||
$tid = 1;
|
||||
$settings = array();
|
||||
$settings['type'] = 'article';
|
||||
$settings['field_entityreference_term'][LANGUAGE_NONE][0]['target_id'] = $tid;
|
||||
$node = $this->drupalCreateNode($settings);
|
||||
|
||||
$this->assertEqual(taxonomy_select_nodes($tid), array($node->nid));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -8,9 +8,9 @@ dependencies[] = feeds
|
||||
dependencies[] = feeds_ui
|
||||
dependencies[] = entityreference
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-09-19
|
||||
version = "7.x-1.2"
|
||||
; Information added by Drupal.org packaging script on 2017-08-16
|
||||
version = "7.x-1.5"
|
||||
core = "7.x"
|
||||
project = "entityreference"
|
||||
datestamp = "1474306740"
|
||||
datestamp = "1502895850"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user