Update to Drupal 8.1.2. For more information, see https://www.drupal.org/project/drupal/releases/8.1.2

This commit is contained in:
Pantheon Automation 2016-06-02 15:56:09 -07:00 committed by Greg Anderson
parent 9eae24d844
commit 28556d630e
1322 changed files with 6699 additions and 2064 deletions

View file

@ -69,7 +69,7 @@ function field_help($route_name, RouteMatchInterface $route_match) {
$field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#';
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Field module allows custom data fields to be defined for <em>entity</em> types (see below). The Field module takes care of storing, loading, editing, and rendering field data. Most users will not interact with the Field module directly, but will instead use the <a href=":field-ui-help">Field UI module</a> user interface. Module developers can use the Field API to make new entity types "fieldable" and thus allow fields to be attached to them. For more information, see the <a href=":field">online documentation for the Field module</a>.', array(':field-ui-help' => $field_ui_url, ':field' => 'https://www.drupal.org/documentation/modules/field')). '</p>';
$output .= '<p>' . t('The Field module allows custom data fields to be defined for <em>entity</em> types (see below). The Field module takes care of storing, loading, editing, and rendering field data. Most users will not interact with the Field module directly, but will instead use the <a href=":field-ui-help">Field UI module</a> user interface. Module developers can use the Field API to make new entity types "fieldable" and thus allow fields to be attached to them. For more information, see the <a href=":field">online documentation for the Field module</a>.', array(':field-ui-help' => $field_ui_url, ':field' => 'https://www.drupal.org/documentation/modules/field')) . '</p>';
$output .= '<h3>' . t('Terminology') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Entities and entity types') . '</dt>';

View file

@ -298,7 +298,8 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage.
*
* @throws \Drupal\Core\Field\FieldException If the field definition is invalid.
* @throws \Drupal\Core\Field\FieldException
* If the field definition is invalid.
*/
protected function preSaveNew(EntityStorageInterface $storage) {
$entity_manager = \Drupal::entityManager();

View file

@ -70,4 +70,5 @@ class Field extends DrupalSqlBase {
),
);
}
}

View file

@ -103,4 +103,5 @@ class FieldInstance extends DrupalSqlBase {
),
);
}
}

View file

@ -74,13 +74,13 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase {
// Set created node as default_value.
$field_edit = array(
'default_value_input[' . $field_name . '][0][target_id]' => $referenced_node->getTitle() . ' (' .$referenced_node->id() . ')',
'default_value_input[' . $field_name . '][0][target_id]' => $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')',
);
$this->drupalPostForm('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $field_name, $field_edit, t('Save settings'));
// Check that default value is selected in default value form.
$this->drupalGet('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $field_name);
$this->assertRaw('name="default_value_input[' . $field_name . '][0][target_id]" value="' . $referenced_node->getTitle() .' (' .$referenced_node->id() . ')', 'The default value is selected in instance settings page');
$this->assertRaw('name="default_value_input[' . $field_name . '][0][target_id]" value="' . $referenced_node->getTitle() . ' (' . $referenced_node->id() . ')', 'The default value is selected in instance settings page');
// Check if the ID has been converted to UUID in config entity.
$config_entity = $this->config('field.field.node.reference_content.' . $field_name)->get();
@ -137,8 +137,8 @@ class EntityReferenceFieldDefaultValueTest extends WebTestBase {
// Set created node as default_value.
$field_edit = array(
'default_value_input[' . $field_name . '][0][target_id]' => $referenced_node_type->label() . ' (' .$referenced_node_type->id() . ')',
'default_value_input[' . $field_name . '][1][target_id]' => $referenced_node_type2->label() . ' (' .$referenced_node_type2->id() . ')',
'default_value_input[' . $field_name . '][0][target_id]' => $referenced_node_type->label() . ' (' . $referenced_node_type->id() . ')',
'default_value_input[' . $field_name . '][1][target_id]' => $referenced_node_type2->label() . ' (' . $referenced_node_type2->id() . ')',
);
$this->drupalPostForm('admin/structure/types/manage/reference_content/fields/node.reference_content.' . $field_name, $field_edit, t('Save settings'));

View file

@ -125,4 +125,5 @@ class EntityReferenceFileUploadTest extends WebTestBase {
$this->drupalPostForm(NULL, $edit, 'Save');
$this->assertResponse(200);
}
}

View file

@ -142,7 +142,7 @@ class EntityReferenceIntegrationTest extends WebTestBase {
if ($key == 'content') {
$field_edit['settings[handler_settings][target_bundles][' . $referenced_entities[0]->getEntityTypeId() . ']'] = TRUE;
}
$this->drupalPostForm($this->entityType . '/structure/' . $this->bundle .'/fields/' . $this->entityType . '.' . $this->bundle . '.' . $this->fieldName, $field_edit, t('Save settings'));
$this->drupalPostForm($this->entityType . '/structure/' . $this->bundle . '/fields/' . $this->entityType . '.' . $this->bundle . '.' . $this->fieldName, $field_edit, t('Save settings'));
// Ensure the configuration has the expected dependency on the entity that
// is being used a default value.
$field = FieldConfig::loadByName($this->entityType, $this->bundle, $this->fieldName);

View file

@ -141,4 +141,5 @@ class SelectionTest extends WebTestBase {
$result = $handler->getReferenceableEntities();
$this->assertResults($result);
}
}

View file

@ -88,4 +88,5 @@ class FieldAccessTest extends FieldTestBase {
$this->drupalGet('node/' . $this->node->id());
$this->assertNoText($this->testViewFieldValue);
}
}

View file

@ -58,4 +58,5 @@ abstract class FieldTestBase extends WebTestBase {
$this->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array('@value' => $value)));
}
}
}

View file

@ -230,14 +230,6 @@ class FormTest extends FieldTestBase {
$this->assertRaw(t('@name field is required.', array('@name' => $this->field['label'])), 'Required field with no value fails validation');
}
// function testFieldFormMultiple() {
// $this->field = $this->field_multiple;
// $field_name = $this->field['field_name'];
// $this->instance['field_name'] = $field_name;
// FieldStorageConfig::create($this->field)->save();
// FieldConfig::create($this->instance)->save();
// }
function testFieldFormUnlimited() {
$field_storage = $this->fieldStorageUnlimited;
$field_name = $field_storage['field_name'];

View file

@ -551,11 +551,12 @@ class NumberFieldTest extends WebTestBase {
);
$this->drupalPostForm($field_configuration_url, $edit, t('Save settings'));
// Check if an error message is shown.
$this->assertNoRaw(t('%name is not a valid number.', array('%name' => t('Minimum'))), 'Saved ' . gettype($minimum_value) .' value as minimal value on a ' . $field->getType() . ' field');
$this->assertNoRaw(t('%name is not a valid number.', array('%name' => t('Minimum'))), 'Saved ' . gettype($minimum_value) . ' value as minimal value on a ' . $field->getType() . ' field');
// Check if a success message is shown.
$this->assertRaw(t('Saved %label configuration.', array('%label' => $field->getLabel())));
// Check if the minimum value was actually set.
$this->drupalGet($field_configuration_url);
$this->assertFieldById('edit-settings-min', $minimum_value, 'Minimal ' . gettype($minimum_value) .' value was set on a ' . $field->getType() . ' field.');
$this->assertFieldById('edit-settings-min', $minimum_value, 'Minimal ' . gettype($minimum_value) . ' value was set on a ' . $field->getType() . ' field.');
}
}

View file

@ -97,4 +97,5 @@ class StringFieldTest extends WebTestBase {
$this->setRawContent(\Drupal::service('renderer')->renderRoot($content));
$this->assertText($value, 'Filtered tags are not displayed');
}
}

View file

@ -130,4 +130,5 @@ class TranslationWebTest extends FieldTestBase {
$this->assertTrue($passed, format_string('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->getRevisionId())));
}
}
}

View file

@ -140,4 +140,5 @@ class FieldUpdateTest extends UpdatePathTestBase {
$dependencies += ['module' => []];
$this->assertEqual(in_array('entity_reference', $dependencies['module']), $present);
}
}

View file

@ -137,4 +137,5 @@ class FieldUITest extends FieldTestBase {
$option = $this->xpath('//label[@for="edit-options-value-0"]');
$this->assertEqual(t('False'), (string) $option[0]);
}
}

View file

@ -36,4 +36,5 @@ class TestFieldApplicableFormatter extends FormatterBase {
public function viewElements(FieldItemListInterface $items, $langcode) {
return array('#markup' => 'Nothing to see here');
}
}

View file

@ -66,4 +66,5 @@ class TestFieldDefaultFormatter extends FormatterBase {
return $elements;
}
}

View file

@ -69,4 +69,5 @@ class TestFieldEmptySettingFormatter extends FormatterBase {
return $elements;
}
}

View file

@ -71,4 +71,5 @@ class TestFieldMultipleFormatter extends FormatterBase {
return $elements;
}
}

View file

@ -79,4 +79,5 @@ class TestFieldPrepareViewFormatter extends FormatterBase {
return $elements;
}
}

View file

@ -21,7 +21,6 @@ use Drupal\Core\Field\FieldDefinitionInterface;
* }
* )
*/
class TestItemWithDependencies extends TestItem {
/**

View file

@ -308,4 +308,5 @@ class DisplayApiTest extends FieldKernelTestBase {
// default "empty" text.
$this->assertText($display['settings']['test_empty_string']);
}
}

View file

@ -66,7 +66,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
// Use Classy theme for testing markup output.
\Drupal::service('theme_handler')->install(['classy']);
\Drupal::service('theme_handler')->setDefault('classy');
$this->installEntitySchema('entity_test');
// Grant the 'view test entity' permission.
$this->installConfig(array('user'));
Role::load(RoleInterface::ANONYMOUS_ID)
@ -195,7 +195,7 @@ class EntityReferenceFormatterTest extends EntityKernelTestBase {
</div>
';
$renderer->renderRoot($build[0]);
$this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() . $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
$this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() . $expected_rendered_name_field_1 . $expected_rendered_body_field_1, sprintf('The markup returned by the %s formatter is correct for an item with a saved entity.', $formatter));
$expected_cache_tags = Cache::mergeTags(\Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(), $this->referencedEntity->getCacheTags());
$expected_cache_tags = Cache::mergeTags($expected_cache_tags, FilterFormat::load('full_html')->getCacheTags());
$this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter)));

View file

@ -370,7 +370,7 @@ class FieldAttachStorageTest extends FieldKernelTestBase {
// Verify that the fields are gone.
$this->assertFalse(FieldConfig::load('entity_test.' . $this->fieldTestData->field->getTargetBundle() . '.' . $this->fieldTestData->field_name), "First field is deleted");
$this->assertFalse(FieldConfig::load('entity_test.' . $field['bundle']. '.' . $field_name), "Second field is deleted");
$this->assertFalse(FieldConfig::load('entity_test.' . $field['bundle'] . '.' . $field_name), "Second field is deleted");
}
}

View file

@ -48,4 +48,5 @@ class FieldImportChangeTest extends FieldKernelTestBase {
$field = FieldConfig::load($field_id);
$this->assertEqual($field->getLabel(), $new_label, 'field label updated');
}
}

View file

@ -115,4 +115,5 @@ class FieldImportCreateTest extends FieldKernelTestBase {
$field = FieldConfig::load($field_id_2b);
$this->assertTrue($field, 'Test import field 2b from sync exists');
}
}

View file

@ -108,4 +108,5 @@ class FieldImportDeleteTest extends FieldKernelTestBase {
$deleted_storages = \Drupal::state()->get('field.storage.deleted') ?: array();
$this->assertTrue(empty($deleted_storages), 'Fields are deleted');
}
}

View file

@ -3,6 +3,7 @@
namespace Drupal\Tests\field\Kernel;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\entity_test\Entity\EntityTest;
@ -84,4 +85,41 @@ class FieldTypePluginManagerTest extends FieldKernelTestBase {
$this->assertEqual($instance->getFieldDefinition()->getDefaultValue($entity), [['value' => 8675309]], 'Instance default_value is 8675309');
}
/**
* Tests all field items provide an existing main property.
*/
public function testMainProperty() {
// Let's enable all Drupal modules in Drupal core, so we test any field
// type plugin.
$this->enableAllCoreModules();
/** @var \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager */
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
foreach ($field_type_manager->getDefinitions() as $plugin_id => $definition) {
$class = $definition['class'];
$property = $class::mainPropertyName();
$storage_definition = BaseFieldDefinition::create($plugin_id);
$property_definitions = $class::propertyDefinitions($storage_definition);
$properties = implode(', ', array_keys($property_definitions));
if (!empty($property_definitions)) {
$message = sprintf("%s property %s found in %s", $plugin_id, $property, $properties);
$this->assertArrayHasKey($property, $class::propertyDefinitions($storage_definition), $message);
}
}
}
/**
* Enable all core modules.
*/
protected function enableAllCoreModules() {
$listing = new ExtensionDiscovery(\Drupal::root());
$module_list = $listing->scan('module', FALSE);
/** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
$module_handler = $this->container->get('module_handler');
$module_list = array_filter(array_keys($module_list), function ($module) use ($module_handler, $module_list) {
return !$module_handler->moduleExists($module) && substr($module_list[$module]->getPath(), 0, 4) === 'core';
});
$this->enableModules($module_list);
}
}

View file

@ -20,7 +20,7 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
*
* @var array
*/
static $modules = array(
public static $modules = array(
'comment',
'datetime',
'file',
@ -76,7 +76,7 @@ class MigrateFieldInstanceTest extends MigrateDrupal7TestBase {
* The expected field label.
* @param string $expected_field_type
* The expected field type.
* @param boolean $is_required
* @param bool $is_required
* Whether or not the field is required.
*/
protected function assertEntity($id, $expected_label, $expected_field_type, $is_required) {

View file

@ -18,7 +18,7 @@ class MigrateFieldTest extends MigrateDrupal7TestBase {
*
* @var array
*/
static $modules = array(
public static $modules = array(
'comment',
'datetime',
'file',

View file

@ -156,4 +156,5 @@ class StringFormatterTest extends KernelTestBase {
$this->assertLink($value, 0);
$this->assertLinkByHref('/entity_test_rev/' . $entity_new_revision->id() . '/revision/' . $entity_new_revision->getRevisionId() . '/view');
}
}

View file

@ -51,4 +51,5 @@ class FieldTypeDefaultsTest extends MigrateProcessTestCase {
sprintf('Failed to lookup field type %s in the static map.', var_export([], TRUE)));
$this->plugin->transform([], $this->migrateExecutable, $this->row, 'property');
}
}