Commit 39dc1313 authored by Dries's avatar Dries
Browse files

- Patch #718254 by andypost: field names were too long -- make PostgreSQL happy.

parent 890ee7f4
......@@ -23,7 +23,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
function setUp() {
parent::setUp('field_sql_storage', 'field', 'field_test', 'text');
$this->field_name = drupal_strtolower($this->randomName() . '_field_name');
$this->field_name = strtolower($this->randomName());
$this->field = array('field_name' => $this->field_name, 'type' => 'test_field', 'cardinality' => 4);
$this->field = field_create_field($this->field);
$this->instance = array(
......@@ -324,9 +324,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
* Test adding and removing indexes while data is present.
*/
function testFieldUpdateIndexesWithData() {
// We do not have a db-agnostic inspection system in core yet, so
// for now we can only test this on mysql.
if (Database::getConnection()->databaseType() == 'mysql') {
// Create a decimal field.
$field_name = 'testfield';
$field = array('field_name' => $field_name, 'type' => 'text');
......@@ -337,9 +335,8 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
// Verify the indexes we will create do not exist yet.
foreach ($tables as $table) {
$indexes = $this->getIndexes($table);
$this->assertTrue(empty($indexes['value']), t("No index named value exists in $table"));
$this->assertTrue(empty($indexes['value_format']), t("No index named value_format exists in $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"));
}
// Add data so the table cannot be dropped.
......@@ -351,17 +348,15 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$field = array('field_name' => $field_name, 'indexes' => array('value' => array('value')));
field_update_field($field);
foreach ($tables as $table) {
$indexes = $this->getIndexes($table);
$this->assertTrue($indexes["{$field_name}_value"] == array(1 => "{$field_name}_value"), t("Index on value created in $table"));
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in $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) {
$indexes = $this->getIndexes($table);
$this->assertTrue($indexes["{$field_name}_value_format"] == array(1 => "{$field_name}_value", 2 => "{$field_name}_format"), t("Index on value_format created in $table"));
$this->assertTrue(empty($indexes["{$field_name}_value"]), t("Index on value removed in $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"));
}
// Verify that the tables were not dropped.
......@@ -369,7 +364,6 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
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"));
}
}
/**
* Test the storage details.
......@@ -398,13 +392,4 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$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)));
}
}
function getIndexes($table) {
$indexes = array();
$result = db_query("SHOW INDEXES FROM {" . $table . "}");
foreach ($result as $row) {
$indexes[$row->key_name][$row->seq_in_index] = $row->column_name;
}
return $indexes;
}
}
......@@ -21,7 +21,7 @@ class ListFieldTestCase extends FieldTestCase {
function setUp() {
parent::setUp('field_test');
$this->field_name = 'field_test';
$this->field_name = 'test_list';
$this->field = array(
'field_name' => $this->field_name,
'type' => 'list',
......@@ -117,15 +117,15 @@ class ListFieldUITestCase extends FieldTestCase {
$this->drupalLogin($admin_user);
// Create content type, with underscores.
$type_name = strtolower($this->randomName(8)) . '_' .'test';
$type_name = 'test_' . strtolower($this->randomName());
$type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
$this->type = $type->type;
// Store a valid URL name, with hyphens instead of underscores.
$this->hyphen_type = str_replace('_', '-', $this->type);
// Create random field name.
$this->field_label = $this->randomName(8);
$this->field_name = 'field_' . strtolower($this->randomName(8));
$this->field_label = $this->randomString();
$this->field_name = strtolower($this->randomName());
}
/**
......
......@@ -207,7 +207,7 @@ class FileFieldRevisionTestCase extends FileFieldTestCase {
*/
function testRevisions() {
$type_name = 'article';
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name);
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
......@@ -297,7 +297,7 @@ class FileFieldDisplayTestCase extends FileFieldTestCase {
* Test normal formatter display on node display.
*/
function testNodeDisplay() {
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$type_name = 'article';
$field_settings = array(
'display_field' => '1',
......@@ -352,7 +352,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
*/
function testRequired() {
$type_name = 'article';
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name, array(), array('required' => '1'));
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
......@@ -398,7 +398,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
*/
function testFileMaxSize() {
$type_name = 'article';
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name, array(), array('required' => '1'));
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
......@@ -450,7 +450,7 @@ class FileFieldValidateTestCase extends FileFieldTestCase {
*/
function testFileExtension() {
$type_name = 'article';
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name);
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
......@@ -507,7 +507,7 @@ class FileFieldPathTestCase extends FileFieldTestCase {
* Test normal formatter display on node display.
*/
function testUploadPath() {
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$type_name = 'article';
$field = $this->createFileField($field_name, $type_name);
$test_file = $this->getTestFile('text');
......
......@@ -570,7 +570,7 @@ class ImageFieldTestCase extends DrupalWebTestCase {
*/
function uploadNodeImage($image, $field_name, $type) {
$edit = array(
'title' => $this->randomName(),
'title' => $this->randomString(),
);
$edit['files[' . $field_name . '_' . LANGUAGE_NONE . '_0]'] = realpath($image->uri);
$this->drupalPost('node/add/' . $type, $edit, t('Save'));
......@@ -598,7 +598,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
* Test image formatters on node display.
*/
function testImageFieldFormatters() {
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$this->createImageField($field_name, 'article');
// Create a new node with an image attached.
......@@ -647,7 +647,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
* Tests for image field settings.
*/
function testImageFieldSettings() {
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$instance_settings = array(
'alt_field' => 1,
'file_extensions' => 'gif jpg jpeg',
......@@ -705,7 +705,7 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
*/
function testImageFieldDefaultImage() {
// Create a new image field.
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$this->createImageField($field_name, 'article');
// Create a new node, with no images and verify that no images are
......@@ -771,7 +771,7 @@ class ImageFieldValidateTestCase extends ImageFieldTestCase {
* Test min/max resolution settings.
*/
function testResolution() {
$field_name = 'field_' . strtolower($this->randomName());
$field_name = strtolower($this->randomName());
$instance_settings = array(
'max_resolution' => '100x100',
'min_resolution' => '50x50',
......
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