update to drupal 7.23
This commit is contained in:
@@ -23,14 +23,20 @@
|
||||
* @see hook_field_extra_fields_alter()
|
||||
*
|
||||
* @return
|
||||
* A nested array of 'pseudo-field' components. Each list is nested within
|
||||
* the following keys: entity type, bundle name, context (either 'form' or
|
||||
* A nested array of 'pseudo-field' elements. Each list is nested within the
|
||||
* following keys: entity type, bundle name, context (either 'form' or
|
||||
* 'display'). The keys are the name of the elements as appearing in the
|
||||
* renderable array (either the entity form or the displayed entity). The
|
||||
* value is an associative array:
|
||||
* - label: The human readable name of the component.
|
||||
* - description: A short description of the component contents.
|
||||
* - label: The human readable name of the element.
|
||||
* - description: A short description of the element contents.
|
||||
* - weight: The default weight of the element.
|
||||
* - edit: (optional) String containing markup (normally a link) used as the
|
||||
* element's 'edit' operation in the administration interface. Only for
|
||||
* 'form' context.
|
||||
* - delete: (optional) String containing markup (normally a link) used as the
|
||||
* element's 'delete' operation in the administration interface. Only for
|
||||
* 'form' context.
|
||||
*/
|
||||
function hook_field_extra_fields() {
|
||||
$extra['node']['poll'] = array(
|
||||
@@ -2508,7 +2514,7 @@ function hook_field_delete_field($field) {
|
||||
*
|
||||
* @param $instance
|
||||
* The instance as it is post-update.
|
||||
* @param $prior_$instance
|
||||
* @param $prior_instance
|
||||
* The instance as it was pre-update.
|
||||
*/
|
||||
function hook_field_update_instance($instance, $prior_instance) {
|
||||
|
@@ -244,9 +244,11 @@ function field_update_field($field) {
|
||||
// $prior_field may no longer be right.
|
||||
module_load_install($field['module']);
|
||||
$schema = (array) module_invoke($field['module'], 'field_schema', $field);
|
||||
$schema += array('columns' => array(), 'indexes' => array());
|
||||
$schema += array('columns' => array(), 'indexes' => array(), 'foreign keys' => array());
|
||||
// 'columns' are hardcoded in the field type.
|
||||
$field['columns'] = $schema['columns'];
|
||||
// 'foreign keys' are hardcoded in the field type.
|
||||
$field['foreign keys'] = $schema['foreign keys'];
|
||||
// 'indexes' can be both hardcoded in the field type, and specified in the
|
||||
// incoming $field definition.
|
||||
$field += array(
|
||||
@@ -522,17 +524,30 @@ function field_create_instance($instance) {
|
||||
* Updates an instance of a field.
|
||||
*
|
||||
* @param $instance
|
||||
* An associative array representing an instance structure. The required
|
||||
* keys and values are:
|
||||
* An associative array representing an instance structure. The following
|
||||
* required array elements specify which field instance is being updated:
|
||||
* - entity_type: The type of the entity the field is attached to.
|
||||
* - bundle: The bundle this field belongs to.
|
||||
* - field_name: The name of an existing field.
|
||||
* Read-only_id properties are assigned automatically. Any other
|
||||
* properties specified in $instance overwrite the existing values for
|
||||
* the instance.
|
||||
* The other array elements represent properties of the instance, and all
|
||||
* properties must be specified or their default values will be used (except
|
||||
* internal-use properties, which are assigned automatically). To avoid
|
||||
* losing the previously stored properties of the instance when making a
|
||||
* change, first load the instance with field_info_instance(), then override
|
||||
* the values you want to override, and finally save using this function.
|
||||
* Example:
|
||||
* @code
|
||||
* // Fetch an instance info array.
|
||||
* $instance_info = field_info_instance($entity_type, $field_name, $bundle_name);
|
||||
* // Change a single property in the instance definition.
|
||||
* $instance_info['definition']['required'] = TRUE;
|
||||
* // Write the changed definition back.
|
||||
* field_update_instance($instance_info['definition']);
|
||||
* @endcode
|
||||
*
|
||||
* @throws FieldException
|
||||
*
|
||||
* @see field_info_instance()
|
||||
* @see field_create_instance()
|
||||
*/
|
||||
function field_update_instance($instance) {
|
||||
|
@@ -11,8 +11,8 @@ dependencies[] = field_sql_storage
|
||||
required = TRUE
|
||||
stylesheets[all][] = theme/field.css
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
datestamp = "1375928238"
|
||||
|
||||
|
@@ -449,6 +449,17 @@ function field_info_bundles($entity_type = NULL) {
|
||||
* - type: The field type.
|
||||
* - bundles: The bundles in which the field appears, as an array with entity
|
||||
* types as keys and the array of bundle names as values.
|
||||
* Example:
|
||||
* @code
|
||||
* array(
|
||||
* 'body' => array(
|
||||
* 'bundles' => array(
|
||||
* 'node' => array('page', 'article'),
|
||||
* ),
|
||||
* 'type' => 'text_with_summary',
|
||||
* ),
|
||||
* );
|
||||
* @endcode
|
||||
*/
|
||||
function field_info_field_map() {
|
||||
$cache = _field_info_field_cache();
|
||||
|
@@ -128,7 +128,7 @@ function field_schema() {
|
||||
'not null' => TRUE,
|
||||
'default' => ''
|
||||
),
|
||||
'entity_type' => array(
|
||||
'entity_type' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 32,
|
||||
'not null' => TRUE,
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = field
|
||||
files[] = field_sql_storage.test
|
||||
required = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
datestamp = "1375928238"
|
||||
|
||||
|
@@ -188,7 +188,7 @@ function _field_sql_storage_schema($field) {
|
||||
foreach ($field['foreign keys'] as $specifier => $specification) {
|
||||
$real_name = _field_sql_storage_indexname($field['field_name'], $specifier);
|
||||
$current['foreign keys'][$real_name]['table'] = $specification['table'];
|
||||
foreach ($specification['columns'] as $column => $referenced) {
|
||||
foreach ($specification['columns'] as $column_name => $referenced) {
|
||||
$sql_storage_column = _field_sql_storage_columnname($field['field_name'], $column_name);
|
||||
$current['foreign keys'][$real_name]['columns'][$sql_storage_column] = $referenced;
|
||||
}
|
||||
|
@@ -126,7 +126,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
|
||||
foreach ($values as $delta => $value) {
|
||||
if ($delta < $this->field['cardinality']) {
|
||||
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Value $delta is inserted correctly"));
|
||||
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], format_string("Value %delta is inserted correctly", array('%delta' => $delta)));
|
||||
}
|
||||
else {
|
||||
$this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets inserted.");
|
||||
@@ -145,7 +145,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
|
||||
foreach ($values as $delta => $value) {
|
||||
if ($delta < $this->field['cardinality']) {
|
||||
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Value $delta is updated correctly"));
|
||||
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], format_string("Value %delta is updated correctly", array('%delta' => $delta)));
|
||||
}
|
||||
else {
|
||||
$this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets updated.");
|
||||
@@ -175,7 +175,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
|
||||
foreach ($values as $delta => $value) {
|
||||
if ($delta < $this->field['cardinality']) {
|
||||
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Update with no field_name entry leaves value $delta untouched"));
|
||||
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], format_string("Update with no field_name entry leaves value %delta untouched", array('%delta' => $delta)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
$entity->{$this->field_name} = NULL;
|
||||
field_attach_update($entity_type, $entity);
|
||||
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
|
||||
$this->assertEqual(count($rows), 0, t("Update with an empty field_name entry empties the field."));
|
||||
$this->assertEqual(count($rows), 0, "Update with an empty field_name entry empties the field.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,7 +326,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Ensure that the field tables are still there.
|
||||
foreach (_field_sql_storage_schema($prior_field) as $table_name => $table_info) {
|
||||
$this->assertTrue(db_table_exists($table_name), t('Table %table exists.', array('%table' => $table_name)));
|
||||
$this->assertTrue(db_table_exists($table_name), format_string('Table %table exists.', array('%table' => $table_name)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,8 +345,8 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Verify the indexes we will create do not exist yet.
|
||||
foreach ($tables as $table) {
|
||||
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), t("No index named value exists in $table"));
|
||||
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), t("No index named value_format exists in $table"));
|
||||
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), format_string("No index named value exists in %table", array('%table' => $table)));
|
||||
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), format_string("No index named value_format exists in %table", array('%table' => $table)));
|
||||
}
|
||||
|
||||
// Add data so the table cannot be dropped.
|
||||
@@ -358,21 +358,21 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value' => array('value')));
|
||||
field_update_field($field);
|
||||
foreach ($tables as $table) {
|
||||
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in $table"));
|
||||
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), format_string("Index on value created in %table", array('%table' => $table)));
|
||||
}
|
||||
|
||||
// Add a different index, removing the existing custom one.
|
||||
$field = array('field_name' => $field_name, 'indexes' => array('value_format' => array('value', 'format')));
|
||||
field_update_field($field);
|
||||
foreach ($tables as $table) {
|
||||
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in $table"));
|
||||
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in $table"));
|
||||
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), format_string("Index on value_format created in %table", array('%table' => $table)));
|
||||
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), format_string("Index on value removed in %table", array('%table' => $table)));
|
||||
}
|
||||
|
||||
// Verify that the tables were not dropped.
|
||||
$entity = field_test_create_stub_entity(0, 0, $instance['bundle']);
|
||||
field_attach_load('test_entity', array(0 => $entity));
|
||||
$this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', t("Index changes performed without dropping the tables"));
|
||||
$this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', "Index changes performed without dropping the tables");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,19 +387,19 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
$instance = field_info_instance($this->instance['entity_type'], $this->instance['field_name'], $this->instance['bundle']);
|
||||
|
||||
// The storage details are indexed by a storage engine type.
|
||||
$this->assertTrue(array_key_exists('sql', $field['storage']['details']), t('The storage type is SQL.'));
|
||||
$this->assertTrue(array_key_exists('sql', $field['storage']['details']), 'The storage type is SQL.');
|
||||
|
||||
// The SQL details are indexed by table name.
|
||||
$details = $field['storage']['details']['sql'];
|
||||
$this->assertTrue(array_key_exists($current, $details[FIELD_LOAD_CURRENT]), t('Table name is available in the instance array.'));
|
||||
$this->assertTrue(array_key_exists($revision, $details[FIELD_LOAD_REVISION]), t('Revision table name is available in the instance array.'));
|
||||
$this->assertTrue(array_key_exists($current, $details[FIELD_LOAD_CURRENT]), 'Table name is available in the instance array.');
|
||||
$this->assertTrue(array_key_exists($revision, $details[FIELD_LOAD_REVISION]), 'Revision table name is available in the instance array.');
|
||||
|
||||
// Test current and revision storage details together because the columns
|
||||
// are the same.
|
||||
foreach ((array) $this->field['columns'] as $column_name => $attributes) {
|
||||
$storage_column_name = _field_sql_storage_columnname($this->field['field_name'], $column_name);
|
||||
$this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $current)));
|
||||
$this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $revision)));
|
||||
$this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, format_string('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $current)));
|
||||
$this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, format_string('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $revision)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,21 +407,35 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
|
||||
* Test foreign key support.
|
||||
*/
|
||||
function testFieldSqlStorageForeignKeys() {
|
||||
// Create a decimal field.
|
||||
// Create a 'shape' field, with a configurable foreign key (see
|
||||
// field_test_field_schema()).
|
||||
$field_name = 'testfield';
|
||||
$field = array('field_name' => $field_name, 'type' => 'text');
|
||||
$field = field_create_field($field);
|
||||
// Retrieve the field and instance with field_info and verify the foreign
|
||||
// keys are in place.
|
||||
$foreign_key_name = 'shape';
|
||||
$field = array('field_name' => $field_name, 'type' => 'shape', 'settings' => array('foreign_key_name' => $foreign_key_name));
|
||||
field_create_field($field);
|
||||
|
||||
// Retrieve the field definition and check that the foreign key is in place.
|
||||
$field = field_info_field($field_name);
|
||||
$this->assertEqual($field['foreign keys']['format']['table'], 'filter_format', t('Foreign key table name preserved through CRUD'));
|
||||
$this->assertEqual($field['foreign keys']['format']['columns']['format'], 'format', t('Foreign key column name preserved through CRUD'));
|
||||
$this->assertEqual($field['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name preserved through CRUD');
|
||||
$this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name preserved through CRUD');
|
||||
|
||||
// Update the field settings, it should update the foreign key definition
|
||||
// too.
|
||||
$foreign_key_name = 'color';
|
||||
$field['settings']['foreign_key_name'] = $foreign_key_name;
|
||||
field_update_field($field);
|
||||
|
||||
// Retrieve the field definition and check that the foreign key is in place.
|
||||
$field = field_info_field($field_name);
|
||||
$this->assertEqual($field['foreign keys'][$foreign_key_name]['table'], $foreign_key_name, 'Foreign key table name modified after update');
|
||||
$this->assertEqual($field['foreign keys'][$foreign_key_name]['columns'][$foreign_key_name], 'id', 'Foreign key column name modified after update');
|
||||
|
||||
// Now grab the SQL schema and verify that too.
|
||||
$schema = drupal_get_schema(_field_sql_storage_tablename($field));
|
||||
$this->assertEqual(count($schema['foreign keys']), 1, t("There is 1 foreign key in the schema"));
|
||||
$schema = drupal_get_schema(_field_sql_storage_tablename($field), TRUE);
|
||||
$this->assertEqual(count($schema['foreign keys']), 1, 'There is 1 foreign key in the schema');
|
||||
$foreign_key = reset($schema['foreign keys']);
|
||||
$filter_column = _field_sql_storage_columnname($field['field_name'], 'format');
|
||||
$this->assertEqual($foreign_key['table'], 'filter_format', t('Foreign key table name preserved in the schema'));
|
||||
$this->assertEqual($foreign_key['columns'][$filter_column], 'format', t('Foreign key column name preserved in the schema'));
|
||||
$foreign_key_column = _field_sql_storage_columnname($field['field_name'], $foreign_key_name);
|
||||
$this->assertEqual($foreign_key['table'], $foreign_key_name, 'Foreign key table name preserved in the schema');
|
||||
$this->assertEqual($foreign_key['columns'][$foreign_key_column], 'id', 'Foreign key column name preserved in the schema');
|
||||
}
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = field
|
||||
dependencies[] = options
|
||||
files[] = tests/list.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
datestamp = "1375928238"
|
||||
|
||||
|
@@ -51,9 +51,9 @@ class ListFieldTestCase extends FieldTestCase {
|
||||
// All three options appear.
|
||||
$entity = field_test_create_stub_entity();
|
||||
$form = drupal_get_form('field_test_entity_form', $entity);
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists'));
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists'));
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists'));
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][1]), 'Option 1 exists');
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists');
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][3]), 'Option 3 exists');
|
||||
|
||||
// Use one of the values in an actual entity, and check that this value
|
||||
// cannot be removed from the list.
|
||||
@@ -77,19 +77,19 @@ class ListFieldTestCase extends FieldTestCase {
|
||||
field_update_field($this->field);
|
||||
$entity = field_test_create_stub_entity();
|
||||
$form = drupal_get_form('field_test_entity_form', $entity);
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist'));
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists'));
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist'));
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][1]), 'Option 1 does not exist');
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists');
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][3]), 'Option 3 does not exist');
|
||||
|
||||
// Completely new options appear.
|
||||
$this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty');
|
||||
field_update_field($this->field);
|
||||
$form = drupal_get_form('field_test_entity_form', $entity);
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist'));
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][2]), t('Option 2 does not exist'));
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][3]), t('Option 3 does not exist'));
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][10]), t('Option 10 exists'));
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][20]), t('Option 20 exists'));
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][1]), 'Option 1 does not exist');
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][2]), 'Option 2 does not exist');
|
||||
$this->assertTrue(empty($form[$this->field_name][$langcode][3]), 'Option 3 does not exist');
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][10]), 'Option 10 exists');
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][20]), 'Option 20 exists');
|
||||
|
||||
// Options are reset when a new field with the same name is created.
|
||||
field_delete_field($this->field_name);
|
||||
@@ -107,9 +107,9 @@ class ListFieldTestCase extends FieldTestCase {
|
||||
$this->instance = field_create_instance($this->instance);
|
||||
$entity = field_test_create_stub_entity();
|
||||
$form = drupal_get_form('field_test_entity_form', $entity);
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists'));
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists'));
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists'));
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][1]), 'Option 1 exists');
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists');
|
||||
$this->assertTrue(!empty($form[$this->field_name][$langcode][3]), 'Option 3 exists');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,20 +233,20 @@ class ListFieldUITestCase extends FieldTestCase {
|
||||
// Flat list of textual values.
|
||||
$string = "Zero\nOne";
|
||||
$array = array('0' => 'Zero', '1' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.');
|
||||
// Explicit integer keys.
|
||||
$string = "0|Zero\n2|Two";
|
||||
$array = array('0' => 'Zero', '2' => 'Two');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Integer keys are accepted.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Integer keys are accepted.');
|
||||
// Check that values can be added and removed.
|
||||
$string = "0|Zero\n1|One";
|
||||
$array = array('0' => 'Zero', '1' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.');
|
||||
// Non-integer keys.
|
||||
$this->assertAllowedValuesInput("1.1|One", 'keys must be integers', t('Non integer keys are rejected.'));
|
||||
$this->assertAllowedValuesInput("abc|abc", 'keys must be integers', t('Non integer keys are rejected.'));
|
||||
$this->assertAllowedValuesInput("1.1|One", 'keys must be integers', 'Non integer keys are rejected.');
|
||||
$this->assertAllowedValuesInput("abc|abc", 'keys must be integers', 'Non integer keys are rejected.');
|
||||
// Mixed list of keyed and unkeyed values.
|
||||
$this->assertAllowedValuesInput("Zero\n1|One", 'invalid input', t('Mixed lists are rejected.'));
|
||||
$this->assertAllowedValuesInput("Zero\n1|One", 'invalid input', 'Mixed lists are rejected.');
|
||||
|
||||
// Create a node with actual data for the field.
|
||||
$settings = array(
|
||||
@@ -256,22 +256,22 @@ class ListFieldUITestCase extends FieldTestCase {
|
||||
$node = $this->drupalCreateNode($settings);
|
||||
|
||||
// Check that a flat list of values is rejected once the field has data.
|
||||
$this->assertAllowedValuesInput( "Zero\nOne", 'invalid input', t('Unkeyed lists are rejected once the field has data.'));
|
||||
$this->assertAllowedValuesInput( "Zero\nOne", 'invalid input', 'Unkeyed lists are rejected once the field has data.');
|
||||
|
||||
// Check that values can be added but values in use cannot be removed.
|
||||
$string = "0|Zero\n1|One\n2|Two";
|
||||
$array = array('0' => 'Zero', '1' => 'One', '2' => 'Two');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values can be added.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values can be added.');
|
||||
$string = "0|Zero\n1|One";
|
||||
$array = array('0' => 'Zero', '1' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
|
||||
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
|
||||
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.');
|
||||
|
||||
// Delete the node, remove the value.
|
||||
node_delete($node->nid);
|
||||
$string = "0|Zero";
|
||||
$array = array('0' => 'Zero');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,19 +284,19 @@ class ListFieldUITestCase extends FieldTestCase {
|
||||
// Flat list of textual values.
|
||||
$string = "Zero\nOne";
|
||||
$array = array('0' => 'Zero', '1' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.');
|
||||
// Explicit numeric keys.
|
||||
$string = "0|Zero\n.5|Point five";
|
||||
$array = array('0' => 'Zero', '0.5' => 'Point five');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Integer keys are accepted.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Integer keys are accepted.');
|
||||
// Check that values can be added and removed.
|
||||
$string = "0|Zero\n.5|Point five\n1.0|One";
|
||||
$array = array('0' => 'Zero', '0.5' => 'Point five', '1' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.');
|
||||
// Non-numeric keys.
|
||||
$this->assertAllowedValuesInput("abc|abc\n", 'each key must be a valid integer or decimal', t('Non numeric keys are rejected.'));
|
||||
$this->assertAllowedValuesInput("abc|abc\n", 'each key must be a valid integer or decimal', 'Non numeric keys are rejected.');
|
||||
// Mixed list of keyed and unkeyed values.
|
||||
$this->assertAllowedValuesInput("Zero\n1|One\n", 'invalid input', t('Mixed lists are rejected.'));
|
||||
$this->assertAllowedValuesInput("Zero\n1|One\n", 'invalid input', 'Mixed lists are rejected.');
|
||||
|
||||
// Create a node with actual data for the field.
|
||||
$settings = array(
|
||||
@@ -306,22 +306,22 @@ class ListFieldUITestCase extends FieldTestCase {
|
||||
$node = $this->drupalCreateNode($settings);
|
||||
|
||||
// Check that a flat list of values is rejected once the field has data.
|
||||
$this->assertAllowedValuesInput("Zero\nOne", 'invalid input', t('Unkeyed lists are rejected once the field has data.'));
|
||||
$this->assertAllowedValuesInput("Zero\nOne", 'invalid input', 'Unkeyed lists are rejected once the field has data.');
|
||||
|
||||
// Check that values can be added but values in use cannot be removed.
|
||||
$string = "0|Zero\n.5|Point five\n2|Two";
|
||||
$array = array('0' => 'Zero', '0.5' => 'Point five', '2' => 'Two');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values can be added.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values can be added.');
|
||||
$string = "0|Zero\n.5|Point five";
|
||||
$array = array('0' => 'Zero', '0.5' => 'Point five');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
|
||||
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
|
||||
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.');
|
||||
|
||||
// Delete the node, remove the value.
|
||||
node_delete($node->nid);
|
||||
$string = "0|Zero";
|
||||
$array = array('0' => 'Zero');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,21 +334,21 @@ class ListFieldUITestCase extends FieldTestCase {
|
||||
// Flat list of textual values.
|
||||
$string = "Zero\nOne";
|
||||
$array = array('Zero' => 'Zero', 'One' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.');
|
||||
// Explicit keys.
|
||||
$string = "zero|Zero\none|One";
|
||||
$array = array('zero' => 'Zero', 'one' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Explicit keys are accepted.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Explicit keys are accepted.');
|
||||
// Check that values can be added and removed.
|
||||
$string = "zero|Zero\ntwo|Two";
|
||||
$array = array('zero' => 'Zero', 'two' => 'Two');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.');
|
||||
// Mixed list of keyed and unkeyed values.
|
||||
$string = "zero|Zero\nOne\n";
|
||||
$array = array('zero' => 'Zero', 'One' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Mixed lists are accepted.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Mixed lists are accepted.');
|
||||
// Overly long keys.
|
||||
$this->assertAllowedValuesInput("zero|Zero\n" . $this->randomName(256) . "|One", 'each key must be a string at most 255 characters long', t('Overly long keys are rejected.'));
|
||||
$this->assertAllowedValuesInput("zero|Zero\n" . $this->randomName(256) . "|One", 'each key must be a string at most 255 characters long', 'Overly long keys are rejected.');
|
||||
|
||||
// Create a node with actual data for the field.
|
||||
$settings = array(
|
||||
@@ -361,22 +361,22 @@ class ListFieldUITestCase extends FieldTestCase {
|
||||
// data.
|
||||
$string = "Zero\nOne";
|
||||
$array = array('Zero' => 'Zero', 'One' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are still accepted once the field has data.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are still accepted once the field has data.');
|
||||
|
||||
// Check that values can be added but values in use cannot be removed.
|
||||
$string = "Zero\nOne\nTwo";
|
||||
$array = array('Zero' => 'Zero', 'One' => 'One', 'Two' => 'Two');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values can be added.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values can be added.');
|
||||
$string = "Zero\nOne";
|
||||
$array = array('Zero' => 'Zero', 'One' => 'One');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
|
||||
$this->assertAllowedValuesInput("Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
|
||||
$this->assertAllowedValuesInput("Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.');
|
||||
|
||||
// Delete the node, remove the value.
|
||||
node_delete($node->nid);
|
||||
$string = "Zero";
|
||||
$array = array('Zero' => 'Zero');
|
||||
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.'));
|
||||
$this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,15 +395,15 @@ class ListFieldUITestCase extends FieldTestCase {
|
||||
'off' => $off,
|
||||
);
|
||||
$this->drupalPost($this->admin_path, $edit, t('Save settings'));
|
||||
$this->assertText("Saved field_list_boolean configuration.", t("The 'On' and 'Off' form fields work for boolean fields."));
|
||||
$this->assertText("Saved field_list_boolean configuration.", "The 'On' and 'Off' form fields work for boolean fields.");
|
||||
// Test the allowed_values on the field settings form.
|
||||
$this->drupalGet($this->admin_path);
|
||||
$this->assertFieldByName('on', $on, t("The 'On' value is stored correctly."));
|
||||
$this->assertFieldByName('off', $off, t("The 'Off' value is stored correctly."));
|
||||
$this->assertFieldByName('on', $on, "The 'On' value is stored correctly.");
|
||||
$this->assertFieldByName('off', $off, "The 'Off' value is stored correctly.");
|
||||
$field = field_info_field($this->field_name);
|
||||
$this->assertEqual($field['settings']['allowed_values'], $allowed_values, t('The allowed value is correct'));
|
||||
$this->assertFalse(isset($field['settings']['on']), t('The on value is not saved into settings'));
|
||||
$this->assertFalse(isset($field['settings']['off']), t('The off value is not saved into settings'));
|
||||
$this->assertEqual($field['settings']['allowed_values'], $allowed_values, 'The allowed value is correct');
|
||||
$this->assertFalse(isset($field['settings']['on']), 'The on value is not saved into settings');
|
||||
$this->assertFalse(isset($field['settings']['off']), 'The off value is not saved into settings');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,8 +5,8 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
datestamp = "1375928238"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = field
|
||||
files[] = number.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
datestamp = "1375928238"
|
||||
|
||||
|
@@ -58,7 +58,7 @@ class NumberFieldTestCase extends DrupalWebTestCase {
|
||||
// Display creation form.
|
||||
$this->drupalGet('test-entity/add/test-bundle');
|
||||
$langcode = LANGUAGE_NONE;
|
||||
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', t('Widget is displayed'));
|
||||
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', 'Widget is displayed');
|
||||
|
||||
// Submit a signed decimal value within the allowed precision and scale.
|
||||
$value = '-1234.5678';
|
||||
@@ -68,8 +68,8 @@ class NumberFieldTestCase extends DrupalWebTestCase {
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match);
|
||||
$id = $match[1];
|
||||
$this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created'));
|
||||
$this->assertRaw(round($value, 2), t('Value is displayed.'));
|
||||
$this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created');
|
||||
$this->assertRaw(round($value, 2), 'Value is displayed.');
|
||||
|
||||
// Try to create entries with more than one decimal separator; assert fail.
|
||||
$wrong_entries = array(
|
||||
@@ -89,7 +89,7 @@ class NumberFieldTestCase extends DrupalWebTestCase {
|
||||
$this->assertText(
|
||||
t('There should only be one decimal separator (@separator)',
|
||||
array('@separator' => $this->field['settings']['decimal_separator'])),
|
||||
t('Correctly failed to save decimal value with more than one decimal point.')
|
||||
'Correctly failed to save decimal value with more than one decimal point.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = field
|
||||
files[] = options.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
datestamp = "1375928238"
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @file
|
||||
* Tests for options.module.
|
||||
*/
|
||||
|
||||
@@ -85,7 +85,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->assertNoFieldChecked("edit-card-1-$langcode-0");
|
||||
$this->assertNoFieldChecked("edit-card-1-$langcode-1");
|
||||
$this->assertNoFieldChecked("edit-card-1-$langcode-2");
|
||||
$this->assertRaw('Some dangerous & unescaped <strong>markup</strong>', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Some dangerous & unescaped <strong>markup</strong>', 'Option text was properly filtered.');
|
||||
|
||||
// Select first option.
|
||||
$edit = array("card_1[$langcode]" => 0);
|
||||
@@ -139,7 +139,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->assertNoFieldChecked("edit-card-2-$langcode-0");
|
||||
$this->assertNoFieldChecked("edit-card-2-$langcode-1");
|
||||
$this->assertNoFieldChecked("edit-card-2-$langcode-2");
|
||||
$this->assertRaw('Some dangerous & unescaped <strong>markup</strong>', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Some dangerous & unescaped <strong>markup</strong>', 'Option text was properly filtered.');
|
||||
|
||||
// Submit form: select first and third options.
|
||||
$edit = array(
|
||||
@@ -178,7 +178,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
"card_2[$langcode][2]" => TRUE,
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.'));
|
||||
$this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.');
|
||||
|
||||
// Submit form: uncheck all options.
|
||||
$edit = array(
|
||||
@@ -225,19 +225,19 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
// Display form.
|
||||
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
|
||||
// A required field without any value has a "none" option.
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- Select a value -'))), t('A required select list has a "Select a value" choice.'));
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- Select a value -'))), 'A required select list has a "Select a value" choice.');
|
||||
|
||||
// With no field data, nothing is selected.
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", '_none');
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 0);
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 1);
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 2);
|
||||
$this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.');
|
||||
|
||||
// Submit form: select invalid 'none' option.
|
||||
$edit = array("card_1[$langcode]" => '_none');
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertRaw(t('!title field is required.', array('!title' => $instance['field_name'])), t('Cannot save a required field when selecting "none" from the select list.'));
|
||||
$this->assertRaw(t('!title field is required.', array('!title' => $instance['field_name'])), 'Cannot save a required field when selecting "none" from the select list.');
|
||||
|
||||
// Submit form: select first option.
|
||||
$edit = array("card_1[$langcode]" => 0);
|
||||
@@ -247,7 +247,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
// Display form: check that the right options are selected.
|
||||
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
|
||||
// A required field with a value has no 'none' option.
|
||||
$this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1-' . $langcode)), t('A required select list with an actual value has no "none" choice.'));
|
||||
$this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1-' . $langcode)), 'A required select list with an actual value has no "none" choice.');
|
||||
$this->assertOptionSelected("edit-card-1-$langcode", 0);
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 1);
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 2);
|
||||
@@ -259,7 +259,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
// Display form.
|
||||
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
|
||||
// A non-required field has a 'none' option.
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- None -'))), t('A non-required select list has a "None" choice.'));
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- None -'))), 'A non-required select list has a "None" choice.');
|
||||
// Submit form: Unselect the option.
|
||||
$edit = array("card_1[$langcode]" => '_none');
|
||||
$this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save'));
|
||||
@@ -276,8 +276,8 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 0);
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 1);
|
||||
$this->assertNoOptionSelected("edit-card-1-$langcode", 2);
|
||||
$this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Group 1', t('Option groups are displayed.'));
|
||||
$this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.');
|
||||
$this->assertRaw('Group 1', 'Option groups are displayed.');
|
||||
|
||||
// Submit form: select first option.
|
||||
$edit = array("card_1[$langcode]" => 0);
|
||||
@@ -323,7 +323,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->assertNoOptionSelected("edit-card-2-$langcode", 0);
|
||||
$this->assertNoOptionSelected("edit-card-2-$langcode", 1);
|
||||
$this->assertNoOptionSelected("edit-card-2-$langcode", 2);
|
||||
$this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.');
|
||||
|
||||
// Submit form: select first and third options.
|
||||
$edit = array("card_2[$langcode][]" => array(0 => 0, 2 => 2));
|
||||
@@ -350,7 +350,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
// Submit form: select the three options while the field accepts only 2.
|
||||
$edit = array("card_2[$langcode][]" => array(0 => 0, 1 => 1, 2 => 2));
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.'));
|
||||
$this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.');
|
||||
|
||||
// Submit form: uncheck all options.
|
||||
$edit = array("card_2[$langcode][]" => array());
|
||||
@@ -374,7 +374,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$instance['required'] = TRUE;
|
||||
field_update_instance($instance);
|
||||
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
|
||||
$this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), t('A required select list does not have an empty key.'));
|
||||
$this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), 'A required select list does not have an empty key.');
|
||||
|
||||
// We do not have to test that a required select list with one option is
|
||||
// auto-selected because the browser does it for us.
|
||||
@@ -393,8 +393,8 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->assertNoOptionSelected("edit-card-2-$langcode", 0);
|
||||
$this->assertNoOptionSelected("edit-card-2-$langcode", 1);
|
||||
$this->assertNoOptionSelected("edit-card-2-$langcode", 2);
|
||||
$this->assertRaw('Some dangerous & unescaped markup', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Group 1', t('Option groups are displayed.'));
|
||||
$this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.');
|
||||
$this->assertRaw('Group 1', 'Option groups are displayed.');
|
||||
|
||||
// Submit form: select first option.
|
||||
$edit = array("card_2[$langcode][]" => array(0 => 0));
|
||||
@@ -438,7 +438,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
// Display form: with no field data, option is unchecked.
|
||||
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
|
||||
$this->assertNoFieldChecked("edit-bool-$langcode");
|
||||
$this->assertRaw('Some dangerous & unescaped <strong>markup</strong>', t('Option text was properly filtered.'));
|
||||
$this->assertRaw('Some dangerous & unescaped <strong>markup</strong>', 'Option text was properly filtered.');
|
||||
|
||||
// Submit form: check the option.
|
||||
$edit = array("bool[$langcode]" => TRUE);
|
||||
@@ -483,13 +483,13 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
|
||||
$this->assertText(
|
||||
'Use field label instead of the "On value" as label ',
|
||||
t('Display setting checkbox available.')
|
||||
'Display setting checkbox available.'
|
||||
);
|
||||
|
||||
$this->assertFieldByXPath(
|
||||
'*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="MyOnValue "]',
|
||||
TRUE,
|
||||
t('Default case shows "On value"')
|
||||
'Default case shows "On value"'
|
||||
);
|
||||
|
||||
// Enable setting
|
||||
@@ -502,16 +502,16 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
$this->drupalGet($fieldEditUrl);
|
||||
$this->assertText(
|
||||
'Use field label instead of the "On value" as label ',
|
||||
t('Display setting checkbox is available')
|
||||
'Display setting checkbox is available'
|
||||
);
|
||||
$this->assertFieldChecked(
|
||||
'edit-instance-widget-settings-display-label',
|
||||
t('Display settings checkbox checked')
|
||||
'Display settings checkbox checked'
|
||||
);
|
||||
$this->assertFieldByXPath(
|
||||
'*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="' . $this->bool['field_name'] . ' "]',
|
||||
TRUE,
|
||||
t('Display label changes label of the checkbox')
|
||||
'Display label changes label of the checkbox'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = field
|
||||
files[] = text.test
|
||||
required = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
datestamp = "1375928238"
|
||||
|
||||
|
@@ -110,8 +110,8 @@ class TextFieldTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Display creation form.
|
||||
$this->drupalGet('test-entity/add/test-bundle');
|
||||
$this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed'));
|
||||
$this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', t('Format selector is not displayed'));
|
||||
$this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed');
|
||||
$this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', 'Format selector is not displayed');
|
||||
|
||||
// Submit with some value.
|
||||
$value = $this->randomName();
|
||||
@@ -121,7 +121,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match);
|
||||
$id = $match[1];
|
||||
$this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created'));
|
||||
$this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created');
|
||||
|
||||
// Display the entity.
|
||||
$entity = field_test_entity_test_load($id);
|
||||
@@ -179,8 +179,8 @@ class TextFieldTestCase extends DrupalWebTestCase {
|
||||
// Display the creation form. Since the user only has access to one format,
|
||||
// no format selector will be displayed.
|
||||
$this->drupalGet('test-entity/add/test-bundle');
|
||||
$this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed'));
|
||||
$this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is not displayed'));
|
||||
$this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed');
|
||||
$this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', 'Format selector is not displayed');
|
||||
|
||||
// Submit with data that should be filtered.
|
||||
$value = '<em>' . $this->randomName() . '</em>';
|
||||
@@ -190,14 +190,14 @@ class TextFieldTestCase extends DrupalWebTestCase {
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match);
|
||||
$id = $match[1];
|
||||
$this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created'));
|
||||
$this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created');
|
||||
|
||||
// Display the entity.
|
||||
$entity = field_test_entity_test_load($id);
|
||||
$entity->content = field_attach_view($entity_type, $entity, 'full');
|
||||
$this->content = drupal_render($entity->content);
|
||||
$this->assertNoRaw($value, t('HTML tags are not displayed.'));
|
||||
$this->assertRaw(check_plain($value), t('Escaped HTML is displayed correctly.'));
|
||||
$this->assertNoRaw($value, 'HTML tags are not displayed.');
|
||||
$this->assertRaw(check_plain($value), 'Escaped HTML is displayed correctly.');
|
||||
|
||||
// Create a new text format that does not escape HTML, and grant the user
|
||||
// access to it.
|
||||
@@ -219,21 +219,21 @@ class TextFieldTestCase extends DrupalWebTestCase {
|
||||
// Display edition form.
|
||||
// We should now have a 'text format' selector.
|
||||
$this->drupalGet('test-entity/manage/' . $id . '/edit');
|
||||
$this->assertFieldByName("{$this->field_name}[$langcode][0][value]", NULL, t('Widget is displayed'));
|
||||
$this->assertFieldByName("{$this->field_name}[$langcode][0][format]", NULL, t('Format selector is displayed'));
|
||||
$this->assertFieldByName("{$this->field_name}[$langcode][0][value]", NULL, 'Widget is displayed');
|
||||
$this->assertFieldByName("{$this->field_name}[$langcode][0][format]", NULL, 'Format selector is displayed');
|
||||
|
||||
// Edit and change the text format to the new one that was created.
|
||||
$edit = array(
|
||||
"{$this->field_name}[$langcode][0][format]" => $format_id,
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Save'));
|
||||
$this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), t('Entity was updated'));
|
||||
$this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated');
|
||||
|
||||
// Display the entity.
|
||||
$entity = field_test_entity_test_load($id);
|
||||
$entity->content = field_attach_view($entity_type, $entity, 'full');
|
||||
$this->content = drupal_render($entity->content);
|
||||
$this->assertRaw($value, t('Value is displayed unfiltered'));
|
||||
$this->assertRaw($value, 'Value is displayed unfiltered');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ class TextSummaryTestCase extends DrupalWebTestCase {
|
||||
*/
|
||||
function callTextSummary($text, $expected, $format = NULL, $size = NULL) {
|
||||
$summary = text_summary($text, $format, $size);
|
||||
$this->assertIdentical($summary, $expected, t('Generated summary "@summary" matches expected "@expected".', array('@summary' => $summary, '@expected' => $expected)));
|
||||
$this->assertIdentical($summary, $expected, format_string('Generated summary "@summary" matches expected "@expected".', array('@summary' => $summary, '@expected' => $expected)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,7 +401,7 @@ class TextSummaryTestCase extends DrupalWebTestCase {
|
||||
$this->drupalPost('node/add/article', $edit, t('Save'));
|
||||
$node = $this->drupalGetNodeByTitle($edit['title']);
|
||||
|
||||
$this->assertIdentical($node->body['und'][0]['summary'], $summary, t('Article with with summary and no body has been submitted.'));
|
||||
$this->assertIdentical($node->body['und'][0]['summary'], $summary, 'Article with with summary and no body has been submitted.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
|
||||
// Set "Article" content type to use multilingual support with translation.
|
||||
$edit = array('language_content_type' => 2);
|
||||
$this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));
|
||||
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), t('Article content type has been updated.'));
|
||||
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), 'Article content type has been updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,7 +464,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
|
||||
$node = $this->drupalGetNodeByTitle($edit['title']);
|
||||
$this->drupalGet("node/$node->nid/translate");
|
||||
$this->clickLink(t('add translation'));
|
||||
$this->assertFieldByXPath("//textarea[@name='body[$langcode][0][value]']", $body, t('The textfield widget is populated.'));
|
||||
$this->assertFieldByXPath("//textarea[@name='body[$langcode][0][value]']", $body, 'The textfield widget is populated.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -476,7 +476,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
|
||||
$edit = array('field[cardinality]' => -1);
|
||||
$this->drupalPost('admin/structure/types/manage/article/fields/body', $edit, t('Save settings'));
|
||||
$this->drupalGet('node/add/article');
|
||||
$this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), t('Body field cardinality set to multiple.'));
|
||||
$this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), 'Body field cardinality set to multiple.');
|
||||
|
||||
$body = array(
|
||||
$this->randomName(),
|
||||
@@ -501,7 +501,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
|
||||
"body[$langcode][$delta][format]" => array_shift($formats),
|
||||
);
|
||||
$this->drupalPost('node/1/edit', $edit, t('Save'));
|
||||
$this->assertText($body[$delta], t('The body field with delta @delta has been saved.', array('@delta' => $delta)));
|
||||
$this->assertText($body[$delta], format_string('The body field with delta @delta has been saved.', array('@delta' => $delta)));
|
||||
}
|
||||
|
||||
// Login as translator.
|
||||
@@ -511,7 +511,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
|
||||
$node = $this->drupalGetNodeByTitle($title);
|
||||
$this->drupalGet("node/$node->nid/translate");
|
||||
$this->clickLink(t('add translation'));
|
||||
$this->assertNoText($body[0], t('The body field with delta @delta is hidden.', array('@delta' => 0)));
|
||||
$this->assertText($body[1], t('The body field with delta @delta is shown.', array('@delta' => 1)));
|
||||
$this->assertNoText($body[0], format_string('The body field with delta @delta is hidden.', array('@delta' => 0)));
|
||||
$this->assertText($body[1], format_string('The body field with delta @delta is shown.', array('@delta' => 1)));
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -28,7 +28,9 @@ function field_test_field_info() {
|
||||
'shape' => array(
|
||||
'label' => t('Shape'),
|
||||
'description' => t('Another dummy field type.'),
|
||||
'settings' => array(),
|
||||
'settings' => array(
|
||||
'foreign_key_name' => 'shape',
|
||||
),
|
||||
'instance_settings' => array(),
|
||||
'default_widget' => 'test_field_widget',
|
||||
'default_formatter' => 'field_test_default',
|
||||
|
@@ -6,8 +6,8 @@ files[] = field_test.entity.inc
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.22"
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
project = "drupal"
|
||||
datestamp = "1365027012"
|
||||
datestamp = "1375928238"
|
||||
|
||||
|
@@ -132,6 +132,18 @@ function field_test_field_schema($field) {
|
||||
);
|
||||
}
|
||||
else {
|
||||
$foreign_keys = array();
|
||||
// The 'foreign keys' key is not always used in tests.
|
||||
if (!empty($field['settings']['foreign_key_name'])) {
|
||||
$foreign_keys['foreign keys'] = array(
|
||||
// This is a dummy foreign key definition, references a table that
|
||||
// doesn't exist, but that's not a problem.
|
||||
$field['settings']['foreign_key_name'] => array(
|
||||
'table' => $field['settings']['foreign_key_name'],
|
||||
'columns' => array($field['settings']['foreign_key_name'] => 'id'),
|
||||
),
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'columns' => array(
|
||||
'shape' => array(
|
||||
@@ -145,6 +157,6 @@ function field_test_field_schema($field) {
|
||||
'not null' => FALSE,
|
||||
),
|
||||
),
|
||||
);
|
||||
) + $foreign_keys;
|
||||
}
|
||||
}
|
||||
|
@@ -204,10 +204,7 @@ function field_test_dummy_field_storage_query(EntityFieldQuery $query) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity label callback.
|
||||
*
|
||||
* @param $entity
|
||||
* The entity object.
|
||||
* Implements callback_entity_info_label().
|
||||
*
|
||||
* @return
|
||||
* The label of the entity prefixed with "label callback".
|
||||
|
Reference in New Issue
Block a user