Commit d3a7d136 authored by alexpott's avatar alexpott

Issue #2376689 by yched: IntegerItem 'size' setting should be a storage setting

parent 9bb4f4cf
......@@ -622,11 +622,15 @@ field.email.value:
# Schema for the configuration of the Integer field type.
field.integer.storage_settings:
type: sequence
type: mapping
label: 'Integer settings'
sequence:
- type: string
label: 'setting'
mapping:
unsigned:
type: boolean
label: 'Unsigned'
size:
type: string
label: 'Database storage size'
field.integer.field_settings:
type: mapping
......@@ -644,9 +648,6 @@ field.integer.field_settings:
suffix:
type: string
label: 'Suffix'
size:
type: string
label: 'Database storage size'
field.integer.value:
type: sequence
......
......@@ -30,6 +30,9 @@ class IntegerItem extends NumericItemBase {
public static function defaultStorageSettings() {
return array(
'unsigned' => FALSE,
// Valid size property values include: 'tiny', 'small', 'medium', 'normal'
// and 'big'.
'size' => 'normal',
) + parent::defaultStorageSettings();
}
......@@ -42,9 +45,6 @@ public static function defaultFieldSettings() {
'max' => '',
'prefix' => '',
'suffix' => '',
// Valid size property values include: 'tiny', 'small', 'medium', 'normal'
// and 'big'.
'size' => 'normal',
) + parent::defaultFieldSettings();
}
......
......@@ -143,11 +143,12 @@ function testNumberIntegerField() {
// Create a field with settings to validate.
$field_name = Unicode::strtolower($this->randomMachineName());
entity_create('field_storage_config', array(
$storage = entity_create('field_storage_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'integer',
))->save();
));
$storage->save();
entity_create('field_config', array(
'field_name' => $field_name,
......@@ -172,6 +173,22 @@ function testNumberIntegerField() {
))
->save();
// Check the storage schema.
$expected = array(
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
'unsigned' => '',
'size' => 'normal'
),
),
'unique keys' => array(),
'indexes' => array(),
'foreign keys' => array()
);
$this->assertEqual($storage->getSchema(), $expected);
// Display creation form.
$this->drupalGet('entity_test/add');
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment