function FieldCrudTestCase::testFieldIndexes
Test creation of indexes on data column.
File
-
modules/
field/ tests/ field.test, line 2598
Class
Code
function testFieldIndexes() {
// Check that indexes specified by the field type are used by default.
$field_definition = array(
'field_name' => 'field_1',
'type' => 'test_field',
);
field_create_field($field_definition);
$field = field_read_field($field_definition['field_name']);
$expected_indexes = array(
'value' => array(
'value',
),
);
$this->assertEqual($field['indexes'], $expected_indexes, 'Field type indexes saved by default');
// Check that indexes specified by the field definition override the field
// type indexes.
$field_definition = array(
'field_name' => 'field_2',
'type' => 'test_field',
'indexes' => array(
'value' => array(),
),
);
field_create_field($field_definition);
$field = field_read_field($field_definition['field_name']);
$expected_indexes = array(
'value' => array(),
);
$this->assertEqual($field['indexes'], $expected_indexes, 'Field definition indexes override field type indexes');
// Check that indexes specified by the field definition add to the field
// type indexes.
$field_definition = array(
'field_name' => 'field_3',
'type' => 'test_field',
'indexes' => array(
'value_2' => array(
'value',
),
),
);
field_create_field($field_definition);
$field = field_read_field($field_definition['field_name']);
$expected_indexes = array(
'value' => array(
'value',
),
'value_2' => array(
'value',
),
);
$this->assertEqual($field['indexes'], $expected_indexes, 'Field definition indexes are merged with field type indexes');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.