Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
@ -137,10 +137,11 @@ class EntityReference extends DisplayPluginBase {
|
|||
$conditions = db_or();
|
||||
|
||||
// Build the condition using the selected search fields.
|
||||
foreach ($style_options['options']['search_fields'] as $field_alias) {
|
||||
if (!empty($field_alias)) {
|
||||
foreach ($style_options['options']['search_fields'] as $field_id) {
|
||||
if (!empty($field_id)) {
|
||||
// Get the table and field names for the checked field.
|
||||
$field = $this->view->query->fields[$this->view->field[$field_alias]->field_alias];
|
||||
$field_alias = $this->view->query->addField($this->view->field[$field_id]->table, $field_id);
|
||||
$field = $this->view->query->fields[$field_alias];
|
||||
// Add an OR condition for the field.
|
||||
$conditions->condition($field['table'] . '.' . $field['field'], $value, 'LIKE');
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class EntityReference extends StylePluginBase {
|
|||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['search_fields'] = array('default' => NULL);
|
||||
$options['search_fields'] = array('default' => array());
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\entity_reference\Tests;
|
||||
|
||||
use Drupal\Core\Entity\Entity;
|
||||
use Drupal\field_ui\Tests\FieldUiTestTrait;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\taxonomy\Entity\Vocabulary;
|
||||
|
@ -45,14 +46,21 @@ class EntityReferenceAdminTest extends WebTestBase {
|
|||
parent::setUp();
|
||||
$this->drupalPlaceBlock('system_breadcrumb_block');
|
||||
|
||||
// Create test user.
|
||||
$admin_user = $this->drupalCreateUser(array('access content', 'administer node fields', 'administer node display', 'administer views'));
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Create a content type, with underscores.
|
||||
$type_name = strtolower($this->randomMachineName(8)) . '_test';
|
||||
$type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
|
||||
$this->type = $type->id();
|
||||
|
||||
// Create test user.
|
||||
$admin_user = $this->drupalCreateUser(array(
|
||||
'access content',
|
||||
'administer node fields',
|
||||
'administer node display',
|
||||
'administer views',
|
||||
'create ' . $type_name . ' content',
|
||||
'edit own ' . $type_name . ' content',
|
||||
));
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -191,10 +199,66 @@ class EntityReferenceAdminTest extends WebTestBase {
|
|||
);
|
||||
$this->drupalPostAjaxForm($bundle_path . '/fields/' . $field_name, $edit, 'settings[handler]');
|
||||
$edit = array(
|
||||
'required' => FALSE,
|
||||
'settings[handler_settings][view][view_and_display]' => 'test_entity_reference_entity_test:entity_reference_1',
|
||||
);
|
||||
$this->drupalPostForm(NULL, $edit, t('Save settings'));
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Create a new view and display it as a entity reference.
|
||||
$edit = array(
|
||||
'id' => 'node_test_view',
|
||||
'label' => 'Node Test View',
|
||||
'show[wizard_key]' => 'node',
|
||||
'page[create]' => 1,
|
||||
'page[title]' => 'Test Node View',
|
||||
'page[path]' => 'test/node/view',
|
||||
'page[style][style_plugin]' => 'default',
|
||||
'page[style][row_plugin]' => 'fields',
|
||||
);
|
||||
$this->drupalPostForm('admin/structure/views/add', $edit, t('Save and edit'));
|
||||
$this->drupalPostForm(NULL, array(), t('Duplicate as Entity Reference'));
|
||||
$this->clickLink(t('Settings'));
|
||||
$edit = array(
|
||||
'style_options[search_fields][title]' => 'title',
|
||||
);
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->drupalPostForm('admin/structure/views/view/node_test_view/edit/entity_reference_1', array(), t('Save'));
|
||||
$this->clickLink(t('Settings'));
|
||||
|
||||
// Create a test entity reference field.
|
||||
$field_name = 'test_entity_ref_field';
|
||||
$edit = array(
|
||||
'new_storage_type' => 'field_ui:entity_reference:node',
|
||||
'label' => 'Test Entity Reference Field',
|
||||
'field_name' => $field_name,
|
||||
);
|
||||
$this->drupalPostForm($bundle_path . '/fields/add-field', $edit, t('Save and continue'));
|
||||
$this->drupalPostForm(NULL, array(), t('Save field settings'));
|
||||
|
||||
// Add the view to the test field.
|
||||
$edit = array(
|
||||
'settings[handler]' => 'views',
|
||||
);
|
||||
$this->drupalPostAjaxForm(NULL, $edit, 'settings[handler]');
|
||||
$edit = array(
|
||||
'required' => FALSE,
|
||||
'settings[handler_settings][view][view_and_display]' => 'node_test_view:entity_reference_1',
|
||||
);
|
||||
$this->drupalPostForm(NULL, $edit, t('Save settings'));
|
||||
|
||||
// Create a node.
|
||||
$edit = array(
|
||||
'title[0][value]' => 'Foo Node',
|
||||
);
|
||||
$this->drupalPostForm('node/add/' . $this->type, $edit, t('Save'));
|
||||
|
||||
// Try to add a new node and fill the entity reference field.
|
||||
$this->drupalGet('node/add/' . $this->type);
|
||||
$result = $this->xpath('//input[@name="field_test_entity_ref_field[0][target_id]" and contains(@data-autocomplete-path, "/entity_reference_autocomplete/node/views/")]');
|
||||
$target_url = $this->getAbsoluteUrl($result[0]['data-autocomplete-path']);
|
||||
$this->drupalGet($target_url, array('query' => array('q' => 'Foo')));
|
||||
$this->assertRaw('Foo');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -188,7 +188,7 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends WebTestBase {
|
|||
'entity_type' => $this->testEntityTypeName,
|
||||
'type' => 'entity_reference',
|
||||
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
|
||||
'translatable' => FALSE,
|
||||
'translatable' => TRUE,
|
||||
'settings' => array(
|
||||
'allowed_values' => array(
|
||||
array(
|
||||
|
@ -292,7 +292,7 @@ class EntityReferenceFieldTranslatedReferenceViewTest extends WebTestBase {
|
|||
'langcode' => $this->baseLangcode,
|
||||
));
|
||||
$node->save();
|
||||
$node->addTranslation($this->translateToLangcode, array());
|
||||
$node->addTranslation($this->translateToLangcode, $node->toArray());
|
||||
$node->save();
|
||||
|
||||
return $node;
|
||||
|
|
Reference in a new issue