Commit 88209f1e authored by Dries's avatar Dries

Issue #1797106 by xjm: Remove t() from asserts messages in tests for the field module.

parent fd5ab152
......@@ -51,18 +51,18 @@ function testCreateField() {
$record['data'] = unserialize($record['data']);
// Ensure that basic properties are preserved.
$this->assertEqual($record['field_name'], $field_definition['field_name'], t('The field name is properly saved.'));
$this->assertEqual($record['type'], $field_definition['type'], t('The field type is properly saved.'));
$this->assertEqual($record['field_name'], $field_definition['field_name'], 'The field name is properly saved.');
$this->assertEqual($record['type'], $field_definition['type'], 'The field type is properly saved.');
// Ensure that cardinality defaults to 1.
$this->assertEqual($record['cardinality'], 1, t('Cardinality defaults to 1.'));
$this->assertEqual($record['cardinality'], 1, 'Cardinality defaults to 1.');
// Ensure that default settings are present.
$field_type = field_info_field_types($field_definition['type']);
$this->assertIdentical($record['data']['settings'], $field_type['settings'], t('Default field settings have been written.'));
$this->assertIdentical($record['data']['settings'], $field_type['settings'], 'Default field settings have been written.');
// Ensure that default storage was set.
$this->assertEqual($record['storage_type'], variable_get('field_storage_default'), t('The field type is properly saved.'));
$this->assertEqual($record['storage_type'], variable_get('field_storage_default'), 'The field type is properly saved.');
// Guarantee that the name is unique.
try {
......@@ -189,7 +189,7 @@ function testReadField() {
// Read the field back.
$field = field_read_field($field_definition['field_name']);
$this->assertTrue($field_definition < $field, t('The field was properly read.'));
$this->assertTrue($field_definition < $field, 'The field was properly read.');
}
/**
......@@ -204,7 +204,7 @@ function testFieldIndexes() {
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, t('Field type indexes saved by default'));
$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.
......@@ -218,7 +218,7 @@ function testFieldIndexes() {
field_create_field($field_definition);
$field = field_read_field($field_definition['field_name']);
$expected_indexes = array('value' => array());
$this->assertEqual($field['indexes'], $expected_indexes, t('Field definition indexes override field type indexes'));
$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.
......@@ -232,7 +232,7 @@ function testFieldIndexes() {
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, t('Field definition indexes are merged with field type indexes'));
$this->assertEqual($field['indexes'], $expected_indexes, 'Field definition indexes are merged with field type indexes');
}
/**
......@@ -263,41 +263,41 @@ function testDeleteField() {
// Test that the first field is not deleted, and then delete it.
$field = field_read_field($this->field['field_name'], array('include_deleted' => TRUE));
$this->assertTrue(!empty($field) && empty($field['deleted']), t('A new field is not marked for deletion.'));
$this->assertTrue(!empty($field) && empty($field['deleted']), 'A new field is not marked for deletion.');
field_delete_field($this->field['field_name']);
// Make sure that the field is marked as deleted when it is specifically
// loaded.
$field = field_read_field($this->field['field_name'], array('include_deleted' => TRUE));
$this->assertTrue(!empty($field['deleted']), t('A deleted field is marked for deletion.'));
$this->assertTrue(!empty($field['deleted']), 'A deleted field is marked for deletion.');
// Make sure that this field's instance is marked as deleted when it is
// specifically loaded.
$instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE));
$this->assertTrue(!empty($instance['deleted']), t('An instance for a deleted field is marked for deletion.'));
$this->assertTrue(!empty($instance['deleted']), 'An instance for a deleted field is marked for deletion.');
// Try to load the field normally and make sure it does not show up.
$field = field_read_field($this->field['field_name']);
$this->assertTrue(empty($field), t('A deleted field is not loaded by default.'));
$this->assertTrue(empty($field), 'A deleted field is not loaded by default.');
// Try to load the instance normally and make sure it does not show up.
$instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$this->assertTrue(empty($instance), t('An instance for a deleted field is not loaded by default.'));
$this->assertTrue(empty($instance), 'An instance for a deleted field is not loaded by default.');
// Make sure the other field (and its field instance) are not deleted.
$another_field = field_read_field($this->another_field['field_name']);
$this->assertTrue(!empty($another_field) && empty($another_field['deleted']), t('A non-deleted field is not marked for deletion.'));
$this->assertTrue(!empty($another_field) && empty($another_field['deleted']), 'A non-deleted field is not marked for deletion.');
$another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']);
$this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('An instance of a non-deleted field is not marked for deletion.'));
$this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), 'An instance of a non-deleted field is not marked for deletion.');
// Try to create a new field the same name as a deleted field and
// write data into it.
field_create_field($this->field);
field_create_instance($this->instance_definition);
$field = field_read_field($this->field['field_name']);
$this->assertTrue(!empty($field) && empty($field['deleted']), t('A new field with a previously used name is created.'));
$this->assertTrue(!empty($field) && empty($field['deleted']), 'A new field with a previously used name is created.');
$instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
$this->assertTrue(!empty($instance) && empty($instance['deleted']), t('A new instance for a previously used field name is created.'));
$this->assertTrue(!empty($instance) && empty($instance['deleted']), 'A new instance for a previously used field name is created.');
// Save an entity with data for the field
$entity = field_test_create_entity(0, 0, $instance['bundle']);
......@@ -450,12 +450,12 @@ function _testActiveHelper($field_definition, $modules) {
// Read the field.
$field = field_read_field($field_name);
$this->assertTrue($field_definition <= $field, t('The field was properly read.'));
$this->assertTrue($field_definition <= $field, 'The field was properly read.');
module_disable($modules, FALSE);
$fields = field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE));
$this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, t('The field is properly read when explicitly fetching inactive fields.'));
$this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, 'The field is properly read when explicitly fetching inactive fields.');
// Re-enable modules one by one, and check that the field is still inactive
// while some modules remain disabled.
......@@ -470,6 +470,6 @@ function _testActiveHelper($field_definition, $modules) {
// Check that the field is active again after all modules have been
// enabled.
$field = field_read_field($field_name);
$this->assertTrue($field_definition <= $field, t('The field was was marked active.'));
$this->assertTrue($field_definition <= $field, 'The field was was marked active.');
}
}
......@@ -77,7 +77,7 @@ function testFieldViewField() {
$this->drupalSetContent(drupal_render($output));
$settings = field_info_formatter_settings('field_test_default');
$setting = $settings['test_formatter_setting'];
$this->assertText($this->label, t('Label was displayed.'));
$this->assertText($this->label, 'Label was displayed.');
foreach ($this->values as $delta => $value) {
$this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
}
......@@ -94,13 +94,13 @@ function testFieldViewField() {
$output = field_view_field('test_entity', $this->entity, $this->field_name, $display);
$this->drupalSetContent(drupal_render($output));
$setting = $display['settings']['test_formatter_setting_multiple'];
$this->assertNoText($this->label, t('Label was not displayed.'));
$this->assertText('field_test_field_attach_view_alter', t('Alter fired, display passed.'));
$this->assertNoText($this->label, 'Label was not displayed.');
$this->assertText('field_test_field_attach_view_alter', 'Alter fired, display passed.');
$array = array();
foreach ($this->values as $delta => $value) {
$array[] = $delta . ':' . $value['value'];
}
$this->assertText($setting . '|' . implode('|', $array), t('Values were displayed with expected setting.'));
$this->assertText($setting . '|' . implode('|', $array), 'Values were displayed with expected setting.');
// Check the prepare_view steps are invoked.
$display = array(
......@@ -114,8 +114,8 @@ function testFieldViewField() {
$view = drupal_render($output);
$this->drupalSetContent($view);
$setting = $display['settings']['test_formatter_setting_additional'];
$this->assertNoText($this->label, t('Label was not displayed.'));
$this->assertNoText('field_test_field_attach_view_alter', t('Alter not fired.'));
$this->assertNoText($this->label, 'Label was not displayed.');
$this->assertNoText('field_test_field_attach_view_alter', 'Alter not fired.');
foreach ($this->values as $delta => $value) {
$this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
}
......@@ -125,7 +125,7 @@ function testFieldViewField() {
$output = field_view_field('test_entity', $this->entity, $this->field_name, 'teaser');
$this->drupalSetContent(drupal_render($output));
$setting = $this->instance['display']['teaser']['settings']['test_formatter_setting'];
$this->assertText($this->label, t('Label was displayed.'));
$this->assertText($this->label, 'Label was displayed.');
foreach ($this->values as $delta => $value) {
$this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
}
......@@ -135,7 +135,7 @@ function testFieldViewField() {
$output = field_view_field('test_entity', $this->entity, $this->field_name, 'unknown_view_mode');
$this->drupalSetContent(drupal_render($output));
$setting = $this->instance['display']['default']['settings']['test_formatter_setting'];
$this->assertText($this->label, t('Label was displayed.'));
$this->assertText($this->label, 'Label was displayed.');
foreach ($this->values as $delta => $value) {
$this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta)));
}
......
......@@ -209,18 +209,18 @@ function testFieldAttachCache() {
$cid = "field:$entity_type:{$entity_init->ftid}";
// Check that no initial cache entry is present.
$this->assertFalse(cache('field')->get($cid), t('Non-cached: no initial cache entry'));
$this->assertFalse(cache('field')->get($cid), 'Non-cached: no initial cache entry');
// Save, and check that no cache entry is present.
$entity = clone($entity_init);
$entity->{$this->field_name}[$langcode] = $values;
field_attach_insert($entity_type, $entity);
$this->assertFalse(cache('field')->get($cid), t('Non-cached: no cache entry on insert'));
$this->assertFalse(cache('field')->get($cid), 'Non-cached: no cache entry on insert');
// Load, and check that no cache entry is present.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertFalse(cache('field')->get($cid), t('Non-cached: no cache entry on load'));
$this->assertFalse(cache('field')->get($cid), 'Non-cached: no cache entry on load');
// Cacheable entity type.
......@@ -231,38 +231,38 @@ function testFieldAttachCache() {
field_create_instance($instance);
// Check that no initial cache entry is present.
$this->assertFalse(cache('field')->get($cid), t('Cached: no initial cache entry'));
$this->assertFalse(cache('field')->get($cid), 'Cached: no initial cache entry');
// Save, and check that no cache entry is present.
$entity = clone($entity_init);
$entity->{$this->field_name}[$langcode] = $values;
field_attach_insert($entity_type, $entity);
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry on insert'));
$this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on insert');
// Load a single field, and check that no cache entry is present.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity), FIELD_LOAD_CURRENT, array('field_id' => $this->field_id));
$cache = cache('field')->get($cid);
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry on loading a single field'));
$this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on loading a single field');
// Load, and check that a cache entry is present with the expected values.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$cache = cache('field')->get($cid);
$this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load'));
$this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load');
// Update with different values, and check that the cache entry is wiped.
$values = $this->_generateTestFieldValues($this->field['cardinality']);
$entity = clone($entity_init);
$entity->{$this->field_name}[$langcode] = $values;
field_attach_update($entity_type, $entity);
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry on update'));
$this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on update');
// Load, and check that a cache entry is present with the expected values.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$cache = cache('field')->get($cid);
$this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load'));
$this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load');
// Create a new revision, and check that the cache entry is wiped.
$entity_init = field_test_create_entity(1, 2, $this->instance['bundle']);
......@@ -271,17 +271,17 @@ function testFieldAttachCache() {
$entity->{$this->field_name}[$langcode] = $values;
field_attach_update($entity_type, $entity);
$cache = cache('field')->get($cid);
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry on new revision creation'));
$this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on new revision creation');
// Load, and check that a cache entry is present with the expected values.
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$cache = cache('field')->get($cid);
$this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load'));
$this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load');
// Delete, and check that the cache entry is wiped.
field_attach_delete($entity_type, $entity);
$this->assertFalse(cache('field')->get($cid), t('Cached: no cache entry after delete'));
$this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry after delete');
}
/**
......@@ -331,7 +331,7 @@ function testFieldAttachValidate() {
catch (FieldValidationException $e) {
$errors = $e->errors;
}
$this->assertEqual($errors[$this->field_name][$langcode][0][0]['error'], 'field_cardinality', t('Cardinality validation failed.'));
$this->assertEqual($errors[$this->field_name][$langcode][0][0]['error'], 'field_cardinality', 'Cardinality validation failed.');
}
......
......@@ -62,7 +62,7 @@ function testFieldAttachSaveLoad() {
$entity = field_test_create_entity(0, 0, $this->instance['bundle']);
field_attach_load($entity_type, array(0 => $entity));
// Number of values per field loaded equals the field cardinality.
$this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], t('Current revision: expected number of values'));
$this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], 'Current revision: expected number of values');
for ($delta = 0; $delta < $this->field['cardinality']; $delta++) {
// The field value loaded matches the one inserted or updated.
$this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'] , $values[$current_revision][$delta]['value'], t('Current revision: expected value %delta was found.', array('%delta' => $delta)));
......@@ -237,14 +237,14 @@ function testFieldStorageDetailsAlter() {
$instance = field_info_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
// The storage details are indexed by a storage engine type.
$this->assertTrue(array_key_exists('drupal_variables', $field['storage']['details']), t('The storage type is Drupal variables.'));
$this->assertTrue(array_key_exists('drupal_variables', $field['storage']['details']), 'The storage type is Drupal variables.');
$details = $field['storage']['details']['drupal_variables'];
// The field_test storage details are indexed by variable name. The details
// are altered, so moon and mars are correct for this test.
$this->assertTrue(array_key_exists('moon', $details[FIELD_LOAD_CURRENT]), t('Moon is available in the instance array.'));
$this->assertTrue(array_key_exists('mars', $details[FIELD_LOAD_REVISION]), t('Mars is available in the instance array.'));
$this->assertTrue(array_key_exists('moon', $details[FIELD_LOAD_CURRENT]), 'Moon is available in the instance array.');
$this->assertTrue(array_key_exists('mars', $details[FIELD_LOAD_REVISION]), 'Mars is available in the instance array.');
// Test current and revision storage details together because the columns
// are the same.
......@@ -268,7 +268,7 @@ function testFieldAttachSaveMissingData() {
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertTrue(empty($entity->{$this->field_name}), t('Insert: missing field results in no value saved'));
$this->assertTrue(empty($entity->{$this->field_name}), 'Insert: missing field results in no value saved');
// Insert: Field is NULL.
field_cache_clear();
......@@ -278,7 +278,7 @@ function testFieldAttachSaveMissingData() {
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertTrue(empty($entity->{$this->field_name}), t('Insert: NULL field results in no value saved'));
$this->assertTrue(empty($entity->{$this->field_name}), 'Insert: NULL field results in no value saved');
// Add some real data.
field_cache_clear();
......@@ -289,7 +289,7 @@ function testFieldAttachSaveMissingData() {
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved'));
$this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Field data saved');
// Update: Field is missing. Data should survive.
field_cache_clear();
......@@ -298,7 +298,7 @@ function testFieldAttachSaveMissingData() {
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Update: missing field leaves existing values in place'));
$this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Update: missing field leaves existing values in place');
// Update: Field is NULL. Data should be wiped.
field_cache_clear();
......@@ -308,7 +308,7 @@ function testFieldAttachSaveMissingData() {
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertTrue(empty($entity->{$this->field_name}), t('Update: NULL field removes existing values'));
$this->assertTrue(empty($entity->{$this->field_name}), 'Update: NULL field removes existing values');
// Re-add some data.
field_cache_clear();
......@@ -319,7 +319,7 @@ function testFieldAttachSaveMissingData() {
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved'));
$this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Field data saved');
// Update: Field is empty array. Data should be wiped.
field_cache_clear();
......@@ -329,7 +329,7 @@ function testFieldAttachSaveMissingData() {
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertTrue(empty($entity->{$this->field_name}), t('Update: empty array removes existing values'));
$this->assertTrue(empty($entity->{$this->field_name}), 'Update: empty array removes existing values');
}
/**
......@@ -351,7 +351,7 @@ function testFieldAttachSaveMissingDataDefaultValue() {
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$this->assertTrue(empty($entity->{$this->field_name}[$langcode]), t('Insert: NULL field results in no value saved'));
$this->assertTrue(empty($entity->{$this->field_name}[$langcode]), 'Insert: NULL field results in no value saved');
// Insert: Field is missing.
field_cache_clear();
......@@ -361,7 +361,7 @@ function testFieldAttachSaveMissingDataDefaultValue() {
$entity = clone($entity_init);
field_attach_load($entity_type, array($entity->ftid => $entity));
$values = field_test_default_value($entity_type, $entity, $this->field, $this->instance);
$this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Insert: missing field results in default value saved'));
$this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Insert: missing field results in default value saved');
}
/**
......@@ -416,7 +416,7 @@ function testFieldAttachDelete() {
}
$read = field_test_create_entity(0, 2, $this->instance['bundle']);
field_attach_load($entity_type, array(0 => $read));
$this->assertIdentical($read->{$this->field_name}, array(), t('The test entity current revision is deleted.'));
$this->assertIdentical($read->{$this->field_name}, array(), 'The test entity current revision is deleted.');
}
/**
......
......@@ -76,16 +76,16 @@ function testFieldInfo() {
);
field_create_field($field);
$fields = field_info_fields();
$this->assertEqual(count($fields), count($core_fields) + 1, t('One new field exists'));
$this->assertEqual($fields[$field['field_name']]['field_name'], $field['field_name'], t('info fields contains field name'));
$this->assertEqual($fields[$field['field_name']]['type'], $field['type'], t('info fields contains field type'));
$this->assertEqual($fields[$field['field_name']]['module'], 'field_test', t('info fields contains field module'));
$this->assertEqual(count($fields), count($core_fields) + 1, 'One new field exists');
$this->assertEqual($fields[$field['field_name']]['field_name'], $field['field_name'], 'info fields contains field name');
$this->assertEqual($fields[$field['field_name']]['type'], $field['type'], 'info fields contains field type');
$this->assertEqual($fields[$field['field_name']]['module'], 'field_test', 'info fields contains field module');
$settings = array('test_field_setting' => 'dummy test string');
foreach ($settings as $key => $val) {
$this->assertEqual($fields[$field['field_name']]['settings'][$key], $val, t("Field setting $key has correct default value $val"));
}
$this->assertEqual($fields[$field['field_name']]['cardinality'], 1, t('info fields contains cardinality 1'));
$this->assertEqual($fields[$field['field_name']]['active'], 1, t('info fields contains active 1'));
$this->assertEqual($fields[$field['field_name']]['cardinality'], 1, 'info fields contains cardinality 1');
$this->assertEqual($fields[$field['field_name']]['active'], 1, 'info fields contains active 1');
// Create an instance, verify that it shows up
$instance = array(
......@@ -103,8 +103,8 @@ function testFieldInfo() {
field_create_instance($instance);
$instances = field_info_instances('test_entity', $instance['bundle']);
$this->assertEqual(count($instances), 1, t('One instance shows up in info when attached to a bundle.'));
$this->assertTrue($instance < $instances[$instance['field_name']], t('Instance appears in info correctly'));
$this->assertEqual(count($instances), 1, 'One instance shows up in info when attached to a bundle.');
$this->assertTrue($instance < $instances[$instance['field_name']], 'Instance appears in info correctly');
// Test a valid entity type but an invalid bundle.
$instances = field_info_instances('test_entity', 'invalid_bundle');
......@@ -154,7 +154,7 @@ function testFieldPrepare() {
// Check that all expected settings are in place.
$field_type = field_info_field_types($field_definition['type']);
$this->assertIdentical($field['settings'], $field_type['settings'], t('All expected default field settings are present.'));
$this->assertIdentical($field['settings'], $field_type['settings'], 'All expected default field settings are present.');
}
/**
......@@ -196,13 +196,13 @@ function testInstancePrepare() {
// Check that all expected instance settings are in place.
$field_type = field_info_field_types($field_definition['type']);
$this->assertIdentical($instance['settings'], $field_type['instance_settings'] , t('All expected instance settings are present.'));
$this->assertIdentical($instance['settings'], $field_type['instance_settings'] , 'All expected instance settings are present.');
// Check that the default widget is used and expected settings are in place.
$widget = $instance->getWidget();
$this->assertIdentical($widget->getPluginId(), $field_type['default_widget'], t('Unavailable widget replaced with default widget.'));
$this->assertIdentical($widget->getPluginId(), $field_type['default_widget'], 'Unavailable widget replaced with default widget.');
$widget_type = $widget->getDefinition();
$this->assertIdentical($widget->getSettings(), $widget_type['settings'] , t('All expected widget settings are present.'));
$this->assertIdentical($widget->getSettings(), $widget_type['settings'] , 'All expected widget settings are present.');
// Check that display settings are set for the 'default' mode.
$display = $instance['display']['default'];
......@@ -231,7 +231,7 @@ function testInstanceDisabledEntityType() {
// Disable coment module. This clears field_info cache.
module_disable(array('comment'));
$this->assertNull(field_info_instance('comment', 'field', 'comment_node_article'), t('No instances are returned on disabled entity types.'));
$this->assertNull(field_info_instance('comment', 'field', 'comment_node_article'), 'No instances are returned on disabled entity types.');
}
/**
......
......@@ -62,7 +62,7 @@ function assertFieldValues($entity, $field_name, $langcode, $expected_values, $c
$e = clone $entity;
field_attach_load('test_entity', array($e->ftid => $e));
$values = isset($e->{$field_name}[$langcode]) ? $e->{$field_name}[$langcode] : array();
$this->assertEqual(count($values), count($expected_values), t('Expected number of values were saved.'));
$this->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.');
foreach ($expected_values as $key => $value) {
$this->assertEqual($values[$key][$column], $value, t('Value @value was saved correctly.', array('@value' => $value)));
}
......
......@@ -93,7 +93,7 @@ function testFieldAvailableLanguages() {
$this->field['translatable'] = FALSE;
field_update_field($this->field);
$available_langcodes = field_available_languages($this->entity_type, $this->field);
$this->assertTrue(count($available_langcodes) == 1 && $available_langcodes[0] === LANGUAGE_NOT_SPECIFIED, t('For untranslatable fields only LANGUAGE_NOT_SPECIFIED is available.'));
$this->assertTrue(count($available_langcodes) == 1 && $available_langcodes[0] === LANGUAGE_NOT_SPECIFIED, 'For untranslatable fields only LANGUAGE_NOT_SPECIFIED is available.');
}
/**
......@@ -131,7 +131,7 @@ function testFieldInvoke() {
$this->assertEqual($hash, $result, t('The result for %language is correctly stored.', array('%language' => $langcode)));
}
$this->assertEqual(count($results), count($available_langcodes), t('No unavailable language has been processed.'));
$this->assertEqual(count($results), count($available_langcodes), 'No unavailable language has been processed.');
}
/**
......@@ -214,7 +214,7 @@ function testTranslatableFieldSaveLoad() {
// Enable field translations for nodes.
field_test_entity_info_translatable('node', TRUE);
$entity_info = entity_get_info('node');
$this->assertTrue(count($entity_info['translation']), t('Nodes are translatable.'));
$this->assertTrue(count($entity_info['translation']), 'Nodes are translatable.');
// Prepare the field translations.
field_test_entity_info_translatable('test_entity', TRUE);
......@@ -223,7 +223,7 @@ function testTranslatableFieldSaveLoad() {
$entity = field_test_create_entity($eid, $evid, $this->instance['bundle']);
$field_translations = array();
$available_langcodes = field_available_languages($entity_type, $this->field);
$this->assertTrue(count($available_langcodes) > 1, t('Field is translatable.'));
$this->assertTrue(count($available_langcodes) > 1, 'Field is translatable.');
foreach ($available_langcodes as $langcode) {
$field_translations[$langcode] = $this->_generateTestFieldValues($this->field['cardinality']);
}
......@@ -334,7 +334,7 @@ function testFieldDisplayLanguage() {
$entity->{$this->field_name}[$requested_langcode] = mt_rand(1, 127);
drupal_static_reset('field_language');
$display_langcode = field_language($entity_type, $entity, $this->field_name, $requested_langcode);
$this->assertEqual($display_langcode, $requested_langcode, t('Display language behave correctly when language fallback is disabled'));
$this->assertEqual($display_langcode, $requested_langcode, 'Display language behave correctly when language fallback is disabled');
}
/**
......
......@@ -404,12 +404,12 @@ function testFieldStorageDetails() {
$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.
......@@ -431,14 +431,14 @@ function testFieldSqlStorageForeignKeys() {
// Retrieve the field and instance with field_info and verify the foreign
// keys are 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']['format']['table'], 'filter_format', 'Foreign key table name preserved through CRUD');
$this->assertEqual($field['foreign keys']['format']['columns']['format'], 'format', 'Foreign key column name preserved through CRUD');
// 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"));
$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'));
$this->assertEqual($foreign_key['table'], 'filter_format', 'Foreign key table name preserved in the schema');
$this->assertEqual($foreign_key['columns'][$filter_column], 'format', 'Foreign key column name preserved in the schema');
}
}
......@@ -71,7 +71,7 @@ function testNumberDecimalField() {
// Display creation form.
$this->drupalGet('test-entity/add/test_bundle');
$langcode = LANGUAGE_NOT_SPECIFIED;
$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';
......@@ -81,8 +81,8 @@ function testNumberDecimalField() {
$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(
......
......@@ -64,9 +64,9 @@ function testUpdateAllowedValues() {
// All three options appear.
$entity = field_test_create_entity();
$form = entity_get_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.
......@@ -90,19 +90,19 @@ function testUpdateAllowedValues() {
field_update_field($this->field);
$entity = field_test_create_entity();
$form = entity_get_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 = entity_get_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);
......@@ -120,8 +120,8 @@ function testUpdateAllowedValues() {
$this->instance = field_create_instance($this->instance);
$entity = field_test_create_entity();
$form = entity_get_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');
}
}
......@@ -100,7 +100,7 @@ function testRadioButtons() {
$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 &amp; unescaped <strong>markup</strong>', t('Option text was properly filtered.'));
$this->assertRaw('Some dangerous &amp; unescaped <strong>markup</strong>', 'Option text was properly filtered.');
// Select first option.
$edit = array("card_1[$langcode]" => 0);
......@@ -154,7 +154,7 @@ function testCheckBoxes() {
$this->assertNoFieldChecked("edit-card-2-$langcode-0");