diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-08-05 23:53:39 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-08-05 23:53:39 +0000 |
commit | 25171a17f626695ecf984cc44b60d3eae1310b4c (patch) | |
tree | 3268ef89294cbb96d0875d665012c4ff16d8c68a /modules/field/tests | |
parent | cacd044a6398df92de68c5aea31987ac0fff507a (diff) | |
download | brdo-25171a17f626695ecf984cc44b60d3eae1310b4c.tar.gz brdo-25171a17f626695ecf984cc44b60d3eae1310b4c.tar.bz2 |
Reverting #500866. Needs more discussion.
Diffstat (limited to 'modules/field/tests')
-rw-r--r-- | modules/field/tests/field.test | 409 |
1 files changed, 205 insertions, 204 deletions
diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index 8038233be..7fbdba694 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -65,9 +65,9 @@ class FieldTestCase extends DrupalWebTestCase { $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), 'Expected number of values were saved.'); + $this->assertEqual(count($values), count($expected_values), t('Expected number of values were saved.')); foreach ($expected_values as $key => $value) { - $this->assertEqual($values[$key][$column], $value, 'Value ' . $value . ' was saved correctly.'); + $this->assertEqual($values[$key][$column], $value, t('Value @value was saved correctly.', array('@value' => $value))); } } } @@ -166,12 +166,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = field_test_create_stub_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'], 'Current revision: expected number of values'); + $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], t('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'], 'Current revision: expected value ' . $delta . ' was found.'); + $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))); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', 'Current revision: extra information for value ' . $delta . ' was found'); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', t('Current revision: extra information for value %delta was found', array('%delta' => $delta))); } // Confirm each revision loads the correct data. @@ -179,12 +179,12 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = field_test_create_stub_entity(0, $revision_id, $this->instance['bundle']); field_attach_load_revision($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'], 'Revision ' . $revision_id . ': expected number of values.'); + $this->assertEqual(count($entity->{$this->field_name}[$langcode]), $this->field['cardinality'], t('Revision %revision_id: expected number of values.', array('%revision_id' => $revision_id))); 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[$revision_id][$delta]['value'], 'Revision ' . $revision_id . ': expected value ' . $delta . ' was found.'); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['value'], $values[$revision_id][$delta]['value'], t('Revision %revision_id: expected value %delta was found.', array('%revision_id' => $revision_id, '%delta' => $delta))); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', 'Revision ' . $revision_id . ': extra information for value ' . $delta . ' was found'); + $this->assertEqual($entity->{$this->field_name}[$langcode][$delta]['additional_key'], 'additional_value', t('Revision %revision_id: extra information for value %delta was found', array('%revision_id' => $revision_id, '%delta' => $delta))); } } } @@ -250,19 +250,19 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $instances = field_info_instances($entity_type, $bundles[$index]); foreach ($instances as $field_name => $instance) { // The field value loaded matches the one inserted. - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], $values[$index][$field_name], 'Entity ' . $index . ': expected value was found.'); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], $values[$index][$field_name], t('Entity %index: expected value was found.', array('%index' => $index))); // The value added in hook_field_load() is found. - $this->assertEqual($entity->{$field_name}[$langcode][0]['additional_key'], 'additional_value', 'Entity ' . $index . ': extra information was found'); + $this->assertEqual($entity->{$field_name}[$langcode][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => $index))); } } // Check that the single-field load option works. $entity = field_test_create_stub_entity(1, 1, $bundles[1]); field_attach_load($entity_type, array(1 => $entity), FIELD_LOAD_CURRENT, array('field_id' => $field_ids[1])); - $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['value'], $values[1][$field_names[1]], 'Entity ' . 1 . ': expected value was found.'); - $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['additional_key'], 'additional_value', 'Entity ' . 1 . ': extra information was found'); - $this->assert(!isset($entity->{$field_names[2]}), 'Entity ' . 2 . ': field ' . $field_names[2] . ' is not loaded.'); - $this->assert(!isset($entity->{$field_names[3]}), 'Entity ' . 3 . ': field ' . $field_names[3] . ' is not loaded.'); + $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['value'], $values[1][$field_names[1]], t('Entity %index: expected value was found.', array('%index' => 1))); + $this->assertEqual($entity->{$field_names[1]}[$langcode][0]['additional_key'], 'additional_value', t('Entity %index: extra information was found', array('%index' => 1))); + $this->assert(!isset($entity->{$field_names[2]}), t('Entity %index: field %field_name is not loaded.', array('%index' => 2, '%field_name' => $field_names[2]))); + $this->assert(!isset($entity->{$field_names[3]}), t('Entity %index: field %field_name is not loaded.', array('%index' => 3, '%field_name' => $field_names[3]))); } /** @@ -312,7 +312,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); foreach ($fields as $field) { - $this->assertEqual($values[$field['field_name']], $entity->{$field['field_name']}[$langcode], $field['storage']['type'] . ' storage: expected values were found.'); + $this->assertEqual($values[$field['field_name']], $entity->{$field['field_name']}[$langcode], t('%storage storage: expected values were found.', array('%storage' => $field['storage']['type']))); } } @@ -341,20 +341,20 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $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']), 'The storage type is Drupal variables.'); + $this->assertTrue(array_key_exists('drupal_variables', $field['storage']['details']), t('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]), 'Moon is available in the instance array.'); - $this->assertTrue(array_key_exists('mars', $details[FIELD_LOAD_REVISION]), 'Mars is available in the instance array.'); + $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.')); // Test current and revision storage details together because the columns // are the same. foreach ((array) $field['columns'] as $column_name => $attributes) { - $this->assertEqual($details[FIELD_LOAD_CURRENT]['moon'][$column_name], $column_name, 'Column name ' . $column_name . ' matches the definition in ' . 'moon[FIELD_LOAD_CURRENT]' . '.'); - $this->assertEqual($details[FIELD_LOAD_REVISION]['mars'][$column_name], $column_name, 'Column name ' . $column_name . ' matches the definition in ' . 'mars[FIELD_LOAD_REVISION]' . '.'); + $this->assertEqual($details[FIELD_LOAD_CURRENT]['moon'][$column_name], $column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'moon[FIELD_LOAD_CURRENT]'))); + $this->assertEqual($details[FIELD_LOAD_REVISION]['mars'][$column_name], $column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => 'mars[FIELD_LOAD_REVISION]'))); } } @@ -372,7 +372,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), 'Insert: missing field results in no value saved'); + $this->assertTrue(empty($entity->{$this->field_name}), t('Insert: missing field results in no value saved')); // Insert: Field is NULL. field_cache_clear(); @@ -382,7 +382,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), 'Insert: NULL field results in no value saved'); + $this->assertTrue(empty($entity->{$this->field_name}), t('Insert: NULL field results in no value saved')); // Add some real data. field_cache_clear(); @@ -393,7 +393,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Field data saved'); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved')); // Update: Field is missing. Data should survive. field_cache_clear(); @@ -402,7 +402,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Update: missing field leaves existing values in place'); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Update: missing field leaves existing values in place')); // Update: Field is NULL. Data should be wiped. field_cache_clear(); @@ -412,7 +412,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), 'Update: NULL field removes existing values'); + $this->assertTrue(empty($entity->{$this->field_name}), t('Update: NULL field removes existing values')); // Re-add some data. field_cache_clear(); @@ -423,7 +423,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertEqual($entity->{$this->field_name}[$langcode], $values, 'Field data saved'); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Field data saved')); // Update: Field is empty array. Data should be wiped. field_cache_clear(); @@ -433,7 +433,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}), 'Update: empty array removes existing values'); + $this->assertTrue(empty($entity->{$this->field_name}), t('Update: empty array removes existing values')); } /** @@ -455,7 +455,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $entity = clone($entity_init); field_attach_load($entity_type, array($entity->ftid => $entity)); - $this->assertTrue(empty($entity->{$this->field_name}[$langcode]), 'Insert: NULL field results in no value saved'); + $this->assertTrue(empty($entity->{$this->field_name}[$langcode]), t('Insert: NULL field results in no value saved')); // Insert: Field is missing. field_cache_clear(); @@ -465,7 +465,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { $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, 'Insert: missing field results in default value saved'); + $this->assertEqual($entity->{$this->field_name}[$langcode], $values, t('Insert: missing field results in default value saved')); } /** @@ -520,7 +520,7 @@ class FieldAttachStorageTestCase extends FieldAttachTestCase { } $read = field_test_create_stub_entity(0, 2, $this->instance['bundle']); field_attach_load($entity_type, array(0 => $read)); - $this->assertIdentical($read->{$this->field_name}, array(), 'The test entity current revision is deleted.'); + $this->assertIdentical($read->{$this->field_name}, array(), t('The test entity current revision is deleted.')); } /** @@ -759,7 +759,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { break; } } - $this->assertTrue($result, 'Variable $' . $this->field_name . ' correctly populated.'); + $this->assertTrue($result, t('Variable $@field_name correctly populated.', array('@field_name' => $this->field_name))); } /** @@ -776,18 +776,18 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $cid = "field:$entity_type:{$entity_init->ftid}"; // Check that no initial cache entry is present. - $this->assertFalse(cache_get($cid, 'cache_field'), 'Non-cached: no initial cache entry'); + $this->assertFalse(cache_get($cid, 'cache_field'), t('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_get($cid, 'cache_field'), 'Non-cached: no cache entry on insert'); + $this->assertFalse(cache_get($cid, 'cache_field'), t('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_get($cid, 'cache_field'), 'Non-cached: no cache entry on load'); + $this->assertFalse(cache_get($cid, 'cache_field'), t('Non-cached: no cache entry on load')); // Cacheable entity type. @@ -798,38 +798,38 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { field_create_instance($instance); // Check that no initial cache entry is present. - $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no initial cache entry'); + $this->assertFalse(cache_get($cid, 'cache_field'), t('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_get($cid, 'cache_field'), 'Cached: no cache entry on insert'); + $this->assertFalse(cache_get($cid, 'cache_field'), t('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_get($cid, 'cache_field'); - $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on loading a single field'); + $this->assertFalse(cache_get($cid, 'cache_field'), t('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_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); + $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('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_get($cid, 'cache_field'), 'Cached: no cache entry on update'); + $this->assertFalse(cache_get($cid, 'cache_field'), t('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_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); + $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); // Create a new revision, and check that the cache entry is wiped. $entity_init = field_test_create_stub_entity(1, 2, $this->instance['bundle']); @@ -838,17 +838,17 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { $entity->{$this->field_name}[$langcode] = $values; field_attach_update($entity_type, $entity); $cache = cache_get($cid, 'cache_field'); - $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry on new revision creation'); + $this->assertFalse(cache_get($cid, 'cache_field'), t('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_get($cid, 'cache_field'); - $this->assertEqual($cache->data[$this->field_name][$langcode], $values, 'Cached: correct cache entry on load'); + $this->assertEqual($cache->data[$this->field_name][$langcode], $values, t('Cached: correct cache entry on load')); // Delete, and check that the cache entry is wiped. field_attach_delete($entity_type, $entity); - $this->assertFalse(cache_get($cid, 'cache_field'), 'Cached: no cache entry after delete'); + $this->assertFalse(cache_get($cid, 'cache_field'), t('Cached: no cache entry after delete')); } /** @@ -898,7 +898,7 @@ class FieldAttachOtherTestCase extends FieldAttachTestCase { catch (FieldValidationException $e) { $errors = $e->errors; } - $this->assertEqual($errors[$this->field_name][$langcode][0][0]['error'], 'field_cardinality', 'Cardinality validation failed.'); + $this->assertEqual($errors[$this->field_name][$langcode][0][0]['error'], 'field_cardinality', t('Cardinality validation failed.')); } @@ -996,39 +996,39 @@ class FieldInfoTestCase extends FieldTestCase { $info = field_info_field_types(); foreach ($field_test_info as $t_key => $field_type) { foreach ($field_type as $key => $val) { - $this->assertEqual($info[$t_key][$key], $val, "Field type $t_key key $key is $val"); + $this->assertEqual($info[$t_key][$key], $val, t("Field type $t_key key $key is $val")); } - $this->assertEqual($info[$t_key]['module'], 'field_test', "Field type field_test module appears"); + $this->assertEqual($info[$t_key]['module'], 'field_test', t("Field type field_test module appears")); } $info = field_info_formatter_types(); foreach ($formatter_info as $f_key => $formatter) { foreach ($formatter as $key => $val) { - $this->assertEqual($info[$f_key][$key], $val, "Formatter type $f_key key $key is $val"); + $this->assertEqual($info[$f_key][$key], $val, t("Formatter type $f_key key $key is $val")); } - $this->assertEqual($info[$f_key]['module'], 'field_test', "Formatter type field_test module appears"); + $this->assertEqual($info[$f_key]['module'], 'field_test', t("Formatter type field_test module appears")); } $info = field_info_widget_types(); foreach ($widget_info as $w_key => $widget) { foreach ($widget as $key => $val) { - $this->assertEqual($info[$w_key][$key], $val, "Widget type $w_key key $key is $val"); + $this->assertEqual($info[$w_key][$key], $val, t("Widget type $w_key key $key is $val")); } - $this->assertEqual($info[$w_key]['module'], 'field_test', "Widget type field_test module appears"); + $this->assertEqual($info[$w_key]['module'], 'field_test', t("Widget type field_test module appears")); } $info = field_info_storage_types(); foreach ($storage_info as $s_key => $storage) { foreach ($storage as $key => $val) { - $this->assertEqual($info[$s_key][$key], $val, "Storage type $s_key key $key is $val"); + $this->assertEqual($info[$s_key][$key], $val, t("Storage type $s_key key $key is $val")); } - $this->assertEqual($info[$s_key]['module'], 'field_test', "Storage type field_test module appears"); + $this->assertEqual($info[$s_key]['module'], 'field_test', t("Storage type field_test module appears")); } // Verify that no unexpected instances exist. $core_fields = field_info_fields(); $instances = field_info_instances('test_entity', 'test_bundle'); - $this->assertTrue(empty($instances), 'With no instances, info bundles is empty.'); + $this->assertTrue(empty($instances), t('With no instances, info bundles is empty.')); // Create a field, verify it shows up. $field = array( @@ -1037,16 +1037,16 @@ class FieldInfoTestCase extends FieldTestCase { ); field_create_field($field); $fields = field_info_fields(); - $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'); + $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')); $settings = array('test_field_setting' => 'dummy test string'); foreach ($settings as $key => $val) { - $this->assertEqual($fields[$field['field_name']]['settings'][$key], $val, "Field setting $key has correct default value $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, 'info fields contains cardinality 1'); - $this->assertEqual($fields[$field['field_name']]['active'], 1, 'info fields contains active 1'); + $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')); // Create an instance, verify that it shows up $instance = array( @@ -1064,8 +1064,8 @@ class FieldInfoTestCase extends FieldTestCase { field_create_instance($instance); $instances = field_info_instances('test_entity', $instance['bundle']); - $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'); + $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')); } /** @@ -1096,7 +1096,7 @@ class FieldInfoTestCase extends FieldTestCase { // Check that all expected settings are in place. $field_type = field_info_field_types($field_definition['type']); - $this->assertIdentical($field['settings'], $field_type['settings'], 'All expected default field settings are present.'); + $this->assertIdentical($field['settings'], $field_type['settings'], t('All expected default field settings are present.')); } /** @@ -1138,18 +1138,18 @@ class FieldInfoTestCase extends FieldTestCase { // 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'], 'All expected instance settings are present.'); + $this->assertIdentical($instance['settings'], $field_type['instance_settings'] , t('All expected instance settings are present.')); // Check that the default widget is used and expected settings are in place. - $this->assertIdentical($instance['widget']['type'], $field_type['default_widget'], 'Unavailable widget replaced with default widget.'); + $this->assertIdentical($instance['widget']['type'], $field_type['default_widget'], t('Unavailable widget replaced with default widget.')); $widget_type = field_info_widget_types($instance['widget']['type']); - $this->assertIdentical($instance['widget']['settings'], $widget_type['settings'], 'All expected widget settings are present.'); + $this->assertIdentical($instance['widget']['settings'], $widget_type['settings'] , t('All expected widget settings are present.')); // Check that display settings are set for the 'default' mode. $display = $instance['display']['default']; - $this->assertIdentical($display['type'], $field_type['default_formatter'], "Formatter is set for the 'default' view mode"); + $this->assertIdentical($display['type'], $field_type['default_formatter'], t("Formatter is set for the 'default' view mode")); $formatter_type = field_info_formatter_types($display['type']); - $this->assertIdentical($display['settings'], $formatter_type['settings'], "Formatter settings are set for the 'default' view mode"); + $this->assertIdentical($display['settings'], $formatter_type['settings'] , t("Formatter settings are set for the 'default' view mode")); } /** @@ -1172,7 +1172,7 @@ class FieldInfoTestCase extends FieldTestCase { // Disable coment module. This clears field_info cache. module_disable(array('comment')); - $this->assertNull(field_info_instance('comment', 'field', 'comment_node_article'), 'No instances are returned on disabled entity types.'); + $this->assertNull(field_info_instance('comment', 'field', 'comment_node_article'), t('No instances are returned on disabled entity types.')); } /** @@ -1319,13 +1319,13 @@ class FieldFormTestCase extends FieldTestCase { $this->assertRaw(t('!name field is required.', array('!name' => $this->instance['label'])), 'Required field with no value fails validation'); } - // function testFieldFormMultiple() { - // $this->field = $this->field_multiple; - // $this->field_name = $this->field['field_name']; - // $this->instance['field_name'] = $this->field_name; - // field_create_field($this->field); - // field_create_instance($this->instance); - // } +// function testFieldFormMultiple() { +// $this->field = $this->field_multiple; +// $this->field_name = $this->field['field_name']; +// $this->instance['field_name'] = $this->field_name; +// field_create_field($this->field); +// field_create_instance($this->instance); +// } function testFieldFormUnlimited() { $this->field = $this->field_unlimited; @@ -1469,7 +1469,7 @@ class FieldFormTestCase extends FieldTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertFieldByName("{$this->field_name}[$langcode]", '', 'Widget is displayed.'); + $this->assertFieldByName("{$this->field_name}[$langcode]", '', t('Widget is displayed.')); // Create entity with three values. $edit = array("{$this->field_name}[$langcode]" => '1, 2, 3'); @@ -1483,12 +1483,12 @@ class FieldFormTestCase extends FieldTestCase { // Display the form, check that the values are correctly filled in. $this->drupalGet('test-entity/' . $id . '/edit'); - $this->assertFieldByName("{$this->field_name}[$langcode]", '1, 2, 3', 'Widget is displayed.'); + $this->assertFieldByName("{$this->field_name}[$langcode]", '1, 2, 3', t('Widget is displayed.')); // Submit the form with more values than the field accepts. $edit = array("{$this->field_name}[$langcode]" => '1, 2, 3, 4, 5'); $this->drupalPost(NULL, $edit, t('Save')); - $this->assertRaw('this field cannot hold more than 4 values', 'Form validation failed.'); + $this->assertRaw('this field cannot hold more than 4 values', t('Form validation failed.')); // Check that the field values were not submitted. $this->assertFieldValues($entity_init, $this->field_name, $langcode, array(1, 2, 3)); } @@ -1524,7 +1524,7 @@ class FieldFormTestCase extends FieldTestCase { // Display creation form. $this->drupalGet('test-entity/add/test-bundle'); - $this->assertNoFieldByName("{$field_name_no_access}[$langcode][0][value]", '', 'Widget is not displayed if field access is denied.'); + $this->assertNoFieldByName("{$field_name_no_access}[$langcode][0][value]", '', t('Widget is not displayed if field access is denied.')); // Create entity. $edit = array("{$field_name}[$langcode][0][value]" => 1); @@ -1534,8 +1534,8 @@ class FieldFormTestCase extends FieldTestCase { // Check that the default value was saved. $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'Default value was saved for the field with no edit access.'); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 1, 'Entered value vas saved for the field with edit access.'); + $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('Default value was saved for the field with no edit access.')); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 1, t('Entered value vas saved for the field with edit access.')); // Create a new revision. $edit = array("{$field_name}[$langcode][0][value]" => 2, 'revision' => TRUE); @@ -1543,13 +1543,13 @@ class FieldFormTestCase extends FieldTestCase { // Check that the new revision has the expected values. $entity = field_test_entity_test_load($id); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'New revision has the expected value for the field with no edit access.'); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, 'New revision has the expected value for the field with edit access.'); + $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); // Check that the revision is also saved in the revisions table. $entity = field_test_entity_test_load($id, $entity->ftvid); - $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, 'New revision has the expected value for the field with no edit access.'); - $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, 'New revision has the expected value for the field with edit access.'); + $this->assertEqual($entity->{$field_name_no_access}[$langcode][0]['value'], 99, t('New revision has the expected value for the field with no edit access.')); + $this->assertEqual($entity->{$field_name}[$langcode][0]['value'], 2, t('New revision has the expected value for the field with edit access.')); } } @@ -1615,9 +1615,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $this->drupalSetContent(drupal_render($output)); $settings = field_info_formatter_settings('field_test_default'); $setting = $settings['test_formatter_setting']; - $this->assertText($this->label, 'Label was displayed.'); - foreach ($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); + $this->assertText($this->label, t('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))); } // Check that explicit display settings are used. @@ -1631,12 +1631,12 @@ class FieldDisplayAPITestCase extends FieldTestCase { $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, 'Label was not displayed.'); + $this->assertNoText($this->label, t('Label was not displayed.')); $array = array(); - foreach ($this->values as $delta => $value) { + foreach($this->values as $delta => $value) { $array[] = $delta . ':' . $value['value']; } - $this->assertText($setting . '|' . implode('|', $array), 'Values were displayed with expected setting.'); + $this->assertText($setting . '|' . implode('|', $array), t('Values were displayed with expected setting.')); // Check the prepare_view steps are invoked. $display = array( @@ -1650,9 +1650,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $view = drupal_render($output); $this->drupalSetContent($view); $setting = $display['settings']['test_formatter_setting_additional']; - $this->assertNoText($this->label, 'Label was not displayed.'); + $this->assertNoText($this->label, t('Label was not displayed.')); foreach ($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), 'Value ' . $delta . ' was displayed with expected setting.'); + $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // View mode: check that display settings specified in the instance are @@ -1660,9 +1660,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $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, 'Label was displayed.'); - foreach ($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); + $this->assertText($this->label, t('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))); } // Unknown view mode: check that display settings for 'default' view mode @@ -1670,9 +1670,9 @@ class FieldDisplayAPITestCase extends FieldTestCase { $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, 'Label was displayed.'); - foreach ($this->values as $delta => $value) { - $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); + $this->assertText($this->label, t('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))); } } @@ -1687,7 +1687,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); + $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // Check that explicit display settings are used. @@ -1703,7 +1703,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|0:' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); + $this->assertText($setting . '|0:' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // Check that prepare_view steps are invoked. @@ -1719,7 +1719,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, $display); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), 'Value ' . $delta . ' was displayed with expected setting.'); + $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // View mode: check that display settings specified in the instance are @@ -1729,7 +1729,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'teaser'); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); + $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // Unknown view mode: check that display settings for 'default' view mode @@ -1739,7 +1739,7 @@ class FieldDisplayAPITestCase extends FieldTestCase { $item = $this->entity->{$this->field_name}[LANGUAGE_NONE][$delta]; $output = field_view_value('test_entity', $this->entity, $this->field_name, $item, 'unknown_view_mode'); $this->drupalSetContent(drupal_render($output)); - $this->assertText($setting . '|' . $value['value'], 'Value ' . $delta . ' was displayed with expected setting.'); + $this->assertText($setting . '|' . $value['value'], t('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } } } @@ -1782,26 +1782,26 @@ class FieldCrudTestCase extends FieldTestCase { $record['data'] = unserialize($record['data']); // Ensure that basic properties are preserved. - $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.'); + $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.')); // Ensure that cardinality defaults to 1. - $this->assertEqual($record['cardinality'], 1, 'Cardinality defaults to 1.'); + $this->assertEqual($record['cardinality'], 1, t('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'], 'Default field settings have been written.'); + $this->assertIdentical($record['data']['settings'], $field_type['settings'], t('Default field settings have been written.')); // Ensure that default storage was set. - $this->assertEqual($record['storage_type'], variable_get('field_storage_default'), 'The field type is properly saved.'); + $this->assertEqual($record['storage_type'], variable_get('field_storage_default'), t('The field type is properly saved.')); // Guarantee that the name is unique. try { field_create_field($field_definition); - $this->fail('Cannot create two fields with the same name.'); + $this->fail(t('Cannot create two fields with the same name.')); } catch (FieldException $e) { - $this->pass('Cannot create two fields with the same name.'); + $this->pass(t('Cannot create two fields with the same name.')); } // Check that field type is required. @@ -1810,10 +1810,10 @@ class FieldCrudTestCase extends FieldTestCase { 'field_name' => 'field_1', ); field_create_field($field_definition); - $this->fail('Cannot create a field with no type.'); + $this->fail(t('Cannot create a field with no type.')); } catch (FieldException $e) { - $this->pass('Cannot create a field with no type.'); + $this->pass(t('Cannot create a field with no type.')); } // Check that field name is required. @@ -1822,10 +1822,10 @@ class FieldCrudTestCase extends FieldTestCase { 'type' => 'test_field' ); field_create_field($field_definition); - $this->fail('Cannot create an unnamed field.'); + $this->fail(t('Cannot create an unnamed field.')); } catch (FieldException $e) { - $this->pass('Cannot create an unnamed field.'); + $this->pass(t('Cannot create an unnamed field.')); } // Check that field name must start with a letter or _. @@ -1835,10 +1835,10 @@ class FieldCrudTestCase extends FieldTestCase { 'type' => 'test_field', ); field_create_field($field_definition); - $this->fail('Cannot create a field with a name starting with a digit.'); + $this->fail(t('Cannot create a field with a name starting with a digit.')); } catch (FieldException $e) { - $this->pass('Cannot create a field with a name starting with a digit.'); + $this->pass(t('Cannot create a field with a name starting with a digit.')); } // Check that field name must only contain lowercase alphanumeric or _. @@ -1848,10 +1848,10 @@ class FieldCrudTestCase extends FieldTestCase { 'type' => 'test_field', ); field_create_field($field_definition); - $this->fail('Cannot create a field with a name containing an illegal character.'); + $this->fail(t('Cannot create a field with a name containing an illegal character.')); } catch (FieldException $e) { - $this->pass('Cannot create a field with a name containing an illegal character.'); + $this->pass(t('Cannot create a field with a name containing an illegal character.')); } // Check that field name cannot be longer than 32 characters long. @@ -1861,10 +1861,10 @@ class FieldCrudTestCase extends FieldTestCase { 'type' => 'test_field', ); field_create_field($field_definition); - $this->fail('Cannot create a field with a name longer than 32 characters.'); + $this->fail(t('Cannot create a field with a name longer than 32 characters.')); } catch (FieldException $e) { - $this->pass('Cannot create a field with a name longer than 32 characters.'); + $this->pass(t('Cannot create a field with a name longer than 32 characters.')); } // Check that field name can not be an entity key. @@ -1875,10 +1875,10 @@ class FieldCrudTestCase extends FieldTestCase { 'field_name' => 'ftvid', ); $field = field_create_field($field_definition); - $this->fail('Cannot create a field bearing the name of an entity key.'); + $this->fail(t('Cannot create a field bearing the name of an entity key.')); } catch (FieldException $e) { - $this->pass('Cannot create a field bearing the name of an entity key.'); + $this->pass(t('Cannot create a field bearing the name of an entity key.')); } } @@ -1920,7 +1920,7 @@ class FieldCrudTestCase extends FieldTestCase { // Read the field back. $field = field_read_field($field_definition['field_name']); - $this->assertTrue($field_definition < $field, 'The field was properly read.'); + $this->assertTrue($field_definition < $field, t('The field was properly read.')); } /** @@ -1935,7 +1935,7 @@ class FieldCrudTestCase extends FieldTestCase { 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'); + $this->assertEqual($field['indexes'], $expected_indexes, t('Field type indexes saved by default')); // Check that indexes specified by the field definition override the field // type indexes. @@ -1949,7 +1949,7 @@ class FieldCrudTestCase extends FieldTestCase { 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'); + $this->assertEqual($field['indexes'], $expected_indexes, t('Field definition indexes override field type indexes')); // Check that indexes specified by the field definition add to the field // type indexes. @@ -1963,7 +1963,7 @@ class FieldCrudTestCase extends FieldTestCase { 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'); + $this->assertEqual($field['indexes'], $expected_indexes, t('Field definition indexes are merged with field type indexes')); } /** @@ -1994,41 +1994,41 @@ class FieldCrudTestCase extends FieldTestCase { // 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']), 'A new field is not marked for deletion.'); + $this->assertTrue(!empty($field) && empty($field['deleted']), t('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']), 'A deleted field is marked for deletion.'); + $this->assertTrue(!empty($field['deleted']), t('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']), 'An instance for a deleted field is marked for deletion.'); + $this->assertTrue(!empty($instance['deleted']), t('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), 'A deleted field is not loaded by default.'); + $this->assertTrue(empty($field), t('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), 'An instance for a deleted field is not loaded by default.'); + $this->assertTrue(empty($instance), t('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']), 'A non-deleted field is not marked for deletion.'); + $this->assertTrue(!empty($another_field) && empty($another_field['deleted']), t('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']), 'An instance of a non-deleted field is not marked for deletion.'); + $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('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']), 'A new field with a previously used name is created.'); + $this->assertTrue(!empty($field) && empty($field['deleted']), t('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']), 'A new instance for a previously used field name is created.'); + $this->assertTrue(!empty($instance) && empty($instance['deleted']), t('A new instance for a previously used field name is created.')); // Save an entity with data for the field $entity = field_test_create_stub_entity(0, 0, $instance['bundle']); @@ -2051,10 +2051,10 @@ class FieldCrudTestCase extends FieldTestCase { $test_field = array('field_name' => 'does_not_exist', 'type' => 'number_decimal'); try { field_update_field($test_field); - $this->fail('Cannot update a field that does not exist.'); + $this->fail(t('Cannot update a field that does not exist.')); } catch (FieldException $e) { - $this->pass('Cannot update a field that does not exist.'); + $this->pass(t('Cannot update a field that does not exist.')); } } @@ -2065,10 +2065,10 @@ class FieldCrudTestCase extends FieldTestCase { $test_field = array('field_name' => 'field_type', 'type' => 'number_integer'); try { field_update_field($test_field); - $this->fail('Cannot update a field to a different type.'); + $this->fail(t('Cannot update a field to a different type.')); } catch (FieldException $e) { - $this->pass('Cannot update a field to a different type.'); + $this->pass(t('Cannot update a field to a different type.')); } } @@ -2126,18 +2126,18 @@ class FieldCrudTestCase extends FieldTestCase { $field['settings']['changeable']++; try { field_update_field($field); - $this->pass("A changeable setting can be updated."); + $this->pass(t("A changeable setting can be updated.")); } catch (FieldException $e) { - $this->fail("An unchangeable setting cannot be updated."); + $this->fail(t("An unchangeable setting cannot be updated.")); } $field['settings']['unchangeable']++; try { field_update_field($field); - $this->fail("An unchangeable setting can be updated."); + $this->fail(t("An unchangeable setting can be updated.")); } catch (FieldException $e) { - $this->pass("An unchangeable setting cannot be updated."); + $this->pass(t("An unchangeable setting cannot be updated.")); } } @@ -2181,18 +2181,18 @@ class FieldCrudTestCase extends FieldTestCase { // Read the field. $field = field_read_field($field_name); - $this->assertTrue($field_definition <= $field, 'The field was properly read.'); + $this->assertTrue($field_definition <= $field, t('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, 'The field is properly read when explicitly fetching inactive fields.'); + $this->assertTrue(isset($fields[$field_name]) && $field_definition < $field, t('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. while ($modules) { $field = field_read_field($field_name); - $this->assertTrue(empty($field), implode(', ', $modules) . ' disabled. The field is marked inactive.'); + $this->assertTrue(empty($field), t('%modules disabled. The field is marked inactive.', array('%modules' => implode(', ', $modules)))); $module = array_shift($modules); module_enable(array($module), FALSE); @@ -2201,7 +2201,7 @@ class FieldCrudTestCase extends FieldTestCase { // Check that the field is active again after all modules have been // enabled. $field = field_read_field($field_name); - $this->assertTrue($field_definition <= $field, 'The field was was marked active.'); + $this->assertTrue($field_definition <= $field, t('The field was was marked active.')); } } @@ -2253,35 +2253,35 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $formatter_type = field_info_formatter_types($field_type['default_formatter']); // Check that default values are set. - $this->assertIdentical($record['data']['required'], FALSE, 'Required defaults to false.'); - $this->assertIdentical($record['data']['label'], $this->instance_definition['field_name'], 'Label defaults to field name.'); - $this->assertIdentical($record['data']['description'], '', 'Description defaults to empty string.'); - $this->assertIdentical($record['data']['widget']['type'], $field_type['default_widget'], 'Default widget has been written.'); - $this->assertTrue(isset($record['data']['display']['default']), 'Display for "full" view_mode has been written.'); - $this->assertIdentical($record['data']['display']['default']['type'], $field_type['default_formatter'], 'Default formatter for "full" view_mode has been written.'); + $this->assertIdentical($record['data']['required'], FALSE, t('Required defaults to false.')); + $this->assertIdentical($record['data']['label'], $this->instance_definition['field_name'], t('Label defaults to field name.')); + $this->assertIdentical($record['data']['description'], '', t('Description defaults to empty string.')); + $this->assertIdentical($record['data']['widget']['type'], $field_type['default_widget'], t('Default widget has been written.')); + $this->assertTrue(isset($record['data']['display']['default']), t('Display for "full" view_mode has been written.')); + $this->assertIdentical($record['data']['display']['default']['type'], $field_type['default_formatter'], t('Default formatter for "full" view_mode has been written.')); // Check that default settings are set. - $this->assertIdentical($record['data']['settings'], $field_type['instance_settings'], 'Default instance settings have been written.'); - $this->assertIdentical($record['data']['widget']['settings'], $widget_type['settings'], 'Default widget settings have been written.'); - $this->assertIdentical($record['data']['display']['default']['settings'], $formatter_type['settings'], 'Default formatter settings for "full" view_mode have been written.'); + $this->assertIdentical($record['data']['settings'], $field_type['instance_settings'] , t('Default instance settings have been written.')); + $this->assertIdentical($record['data']['widget']['settings'], $widget_type['settings'] , t('Default widget settings have been written.')); + $this->assertIdentical($record['data']['display']['default']['settings'], $formatter_type['settings'], t('Default formatter settings for "full" view_mode have been written.')); // Guarantee that the field/bundle combination is unique. try { field_create_instance($this->instance_definition); - $this->fail('Cannot create two instances with the same field / bundle combination.'); + $this->fail(t('Cannot create two instances with the same field / bundle combination.')); } catch (FieldException $e) { - $this->pass('Cannot create two instances with the same field / bundle combination.'); + $this->pass(t('Cannot create two instances with the same field / bundle combination.')); } // Check that the specified field exists. try { $this->instance_definition['field_name'] = $this->randomName(); field_create_instance($this->instance_definition); - $this->fail('Cannot create an instance of a non-existing field.'); + $this->fail(t('Cannot create an instance of a non-existing field.')); } catch (FieldException $e) { - $this->pass('Cannot create an instance of a non-existing field.'); + $this->pass(t('Cannot create an instance of a non-existing field.')); } // Create a field restricted to a specific entity type. @@ -2299,10 +2299,10 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $instance['field_name'] = $field_restricted['field_name']; $instance['entity_type'] = 'test_cacheable_entity'; field_create_instance($instance); - $this->pass('Can create an instance on an entity type allowed by the field.'); + $this->pass(t('Can create an instance on an entity type allowed by the field.')); } catch (FieldException $e) { - $this->fail('Can create an instance on an entity type allowed by the field.'); + $this->fail(t('Can create an instance on an entity type allowed by the field.')); } // Check that an instance cannot be added to an entity type @@ -2311,10 +2311,10 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $instance = $this->instance_definition; $instance['field_name'] = $field_restricted['field_name']; field_create_instance($instance); - $this->fail('Cannot create an instance on an entity type forbidden by the field.'); + $this->fail(t('Cannot create an instance on an entity type forbidden by the field.')); } catch (FieldException $e) { - $this->pass('Cannot create an instance on an entity type forbidden by the field.'); + $this->pass(t('Cannot create an instance on an entity type forbidden by the field.')); } // TODO: test other failures. @@ -2328,7 +2328,7 @@ class FieldInstanceCrudTestCase extends FieldTestCase { // Read the instance back. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue($this->instance_definition < $instance, 'The field was properly read.'); + $this->assertTrue($this->instance_definition < $instance, t('The field was properly read.')); } /** @@ -2344,20 +2344,20 @@ class FieldInstanceCrudTestCase extends FieldTestCase { $instance['label'] = $this->randomName(); $instance['description'] = $this->randomName(); $instance['settings']['test_instance_setting'] = $this->randomName(); - $instance['widget']['settings']['test_widget_setting'] = $this->randomName(); + $instance['widget']['settings']['test_widget_setting'] =$this->randomName(); $instance['widget']['weight']++; $instance['display']['default']['settings']['test_formatter_setting'] = $this->randomName(); $instance['display']['default']['weight']++; field_update_instance($instance); $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertEqual($instance['required'], $instance_new['required'], '"required" change is saved'); - $this->assertEqual($instance['label'], $instance_new['label'], '"label" change is saved'); - $this->assertEqual($instance['description'], $instance_new['description'], '"description" change is saved'); - $this->assertEqual($instance['widget']['settings']['test_widget_setting'], $instance_new['widget']['settings']['test_widget_setting'], 'Widget setting change is saved'); - $this->assertEqual($instance['widget']['weight'], $instance_new['widget']['weight'], 'Widget weight change is saved'); - $this->assertEqual($instance['display']['default']['settings']['test_formatter_setting'], $instance_new['display']['default']['settings']['test_formatter_setting'], 'Formatter setting change is saved'); - $this->assertEqual($instance['display']['default']['weight'], $instance_new['display']['default']['weight'], 'Widget weight change is saved'); + $this->assertEqual($instance['required'], $instance_new['required'], t('"required" change is saved')); + $this->assertEqual($instance['label'], $instance_new['label'], t('"label" change is saved')); + $this->assertEqual($instance['description'], $instance_new['description'], t('"description" change is saved')); + $this->assertEqual($instance['widget']['settings']['test_widget_setting'], $instance_new['widget']['settings']['test_widget_setting'], t('Widget setting change is saved')); + $this->assertEqual($instance['widget']['weight'], $instance_new['widget']['weight'], t('Widget weight change is saved')); + $this->assertEqual($instance['display']['default']['settings']['test_formatter_setting'], $instance_new['display']['default']['settings']['test_formatter_setting'], t('Formatter setting change is saved')); + $this->assertEqual($instance['display']['default']['weight'], $instance_new['display']['default']['weight'], t('Widget weight change is saved')); // Check that changing widget and formatter types updates the default settings. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); @@ -2366,13 +2366,13 @@ class FieldInstanceCrudTestCase extends FieldTestCase { field_update_instance($instance); $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertEqual($instance['widget']['type'], $instance_new['widget']['type'], 'Widget type change is saved.'); + $this->assertEqual($instance['widget']['type'], $instance_new['widget']['type'] , t('Widget type change is saved.')); $settings = field_info_widget_settings($instance_new['widget']['type']); - $this->assertIdentical($settings, array_intersect_key($instance_new['widget']['settings'], $settings), 'Widget type change updates default settings.'); - $this->assertEqual($instance['display']['default']['type'], $instance_new['display']['default']['type'], 'Formatter type change is saved.'); + $this->assertIdentical($settings, array_intersect_key($instance_new['widget']['settings'], $settings) , t('Widget type change updates default settings.')); + $this->assertEqual($instance['display']['default']['type'], $instance_new['display']['default']['type'] , t('Formatter type change is saved.')); $info = field_info_formatter_types($instance_new['display']['default']['type']); $settings = $info['settings']; - $this->assertIdentical($settings, array_intersect_key($instance_new['display']['default']['settings'], $settings), 'Changing formatter type updates default settings.'); + $this->assertIdentical($settings, array_intersect_key($instance_new['display']['default']['settings'], $settings) , t('Changing formatter type updates default settings.')); // Check that adding a new view mode is saved and gets default settings. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); @@ -2380,11 +2380,11 @@ class FieldInstanceCrudTestCase extends FieldTestCase { field_update_instance($instance); $instance_new = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']); - $this->assertTrue(isset($instance_new['display']['teaser']), 'Display for the new view_mode has been written.'); - $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], 'Default formatter for the new view_mode has been written.'); + $this->assertTrue(isset($instance_new['display']['teaser']), t('Display for the new view_mode has been written.')); + $this->assertIdentical($instance_new['display']['teaser']['type'], $field_type['default_formatter'], t('Default formatter for the new view_mode has been written.')); $info = field_info_formatter_types($instance_new['display']['teaser']['type']); $settings = $info['settings']; - $this->assertIdentical($settings, $instance_new['display']['teaser']['settings'], 'Default formatter settings for the new view_mode have been written.'); + $this->assertIdentical($settings, $instance_new['display']['teaser']['settings'] , t('Default formatter settings for the new view_mode have been written.')); // TODO: test failures. } @@ -2406,21 +2406,21 @@ class FieldInstanceCrudTestCase extends FieldTestCase { // Test that the first instance is not deleted, and then delete it. $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle'], array('include_deleted' => TRUE)); - $this->assertTrue(!empty($instance) && empty($instance['deleted']), 'A new field instance is not marked for deletion.'); + $this->assertTrue(!empty($instance) && empty($instance['deleted']), t('A new field instance is not marked for deletion.')); field_delete_instance($instance); // Make sure the instance is marked as deleted when the instance 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']), 'A deleted field instance is marked for deletion.'); + $this->assertTrue(!empty($instance['deleted']), t('A deleted field instance is marked for deletion.')); // 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), 'A deleted field instance is not loaded by default.'); + $this->assertTrue(empty($instance), t('A deleted field instance is not loaded by default.')); // Make sure the other field instance is not deleted. $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']), 'A non-deleted field instance is not marked for deletion.'); + $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('A non-deleted field instance is not marked for deletion.')); } } @@ -2487,17 +2487,17 @@ class FieldTranslationsTestCase extends FieldTestCase { $available_languages = field_available_languages($this->entity_type, $this->field); foreach ($available_languages as $delta => $langcode) { if ($langcode != 'xx' && $langcode != 'en') { - $this->assertTrue(in_array($langcode, $enabled_languages), $langcode . ' is an enabled language.'); + $this->assertTrue(in_array($langcode, $enabled_languages), t('%language is an enabled language.', array('%language' => $langcode))); } } - $this->assertTrue(in_array('xx', $available_languages), 'xx' . ' was made available.'); - $this->assertFalse(in_array('en', $available_languages), 'en' . ' was made unavailable.'); + $this->assertTrue(in_array('xx', $available_languages), t('%language was made available.', array('%language' => 'xx'))); + $this->assertFalse(in_array('en', $available_languages), t('%language was made unavailable.', array('%language' => 'en'))); // Test field_available_languages() behavior for untranslatable fields. $this->field['translatable'] = FALSE; $this->field_name = $this->field['field_name'] = $this->instance['field_name'] = drupal_strtolower($this->randomName() . '_field_name'); $available_languages = field_available_languages($this->entity_type, $this->field); - $this->assertTrue(count($available_languages) == 1 && $available_languages[0] === LANGUAGE_NONE, 'For untranslatable fields only LANGUAGE_NONE is available.'); + $this->assertTrue(count($available_languages) == 1 && $available_languages[0] === LANGUAGE_NONE, t('For untranslatable fields only LANGUAGE_NONE is available.')); } /** @@ -2529,9 +2529,9 @@ class FieldTranslationsTestCase extends FieldTestCase { $hash = hash('sha256', serialize(array($entity_type, $entity, $this->field_name, $langcode, $values[$langcode]))); // Check whether the parameters passed to _field_invoke() were correctly // forwarded to the callback function. - $this->assertEqual($hash, $result, 'The result for ' . $langcode . ' is correctly stored.'); + $this->assertEqual($hash, $result, t('The result for %language is correctly stored.', array('%language' => $langcode))); } - $this->assertEqual(count($results), count($available_languages), 'No unavailable language has been processed.'); + $this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed.')); } /** @@ -2571,9 +2571,9 @@ class FieldTranslationsTestCase extends FieldTestCase { $hash = hash('sha256', serialize(array($entity_type, $entities[$id], $this->field_name, $langcode, $values[$id][$langcode]))); // Check whether the parameters passed to _field_invoke() were correctly // forwarded to the callback function. - $this->assertEqual($hash, $result, 'The result for entity ' . $id . '/' . $langcode . ' is correctly stored.'); + $this->assertEqual($hash, $result, t('The result for entity %id/%language is correctly stored.', array('%id' => $id, '%language' => $langcode))); } - $this->assertEqual(count($results), count($available_languages), 'No unavailable language has been processed for entity ' . $id . '.'); + $this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed for entity %id.', array('%id' => $id))); } } @@ -2584,7 +2584,7 @@ class FieldTranslationsTestCase extends FieldTestCase { // Enable field translations for nodes. field_test_entity_info_translatable('node', TRUE); $entity_info = entity_get_info('node'); - $this->assertTrue(count($entity_info['translation']), 'Nodes are translatable.'); + $this->assertTrue(count($entity_info['translation']), t('Nodes are translatable.')); // Prepare the field translations. field_test_entity_info_translatable('test_entity', TRUE); @@ -2593,7 +2593,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $entity = field_test_create_stub_entity($eid, $evid, $this->instance['bundle']); $field_translations = array(); $available_languages = field_available_languages($entity_type, $this->field); - $this->assertTrue(count($available_languages) > 1, 'Field is translatable.'); + $this->assertTrue(count($available_languages) > 1, t('Field is translatable.')); foreach ($available_languages as $langcode) { $field_translations[$langcode] = $this->_generateTestFieldValues($this->field['cardinality']); } @@ -2610,7 +2610,7 @@ class FieldTranslationsTestCase extends FieldTestCase { foreach ($items as $delta => $item) { $result = $result && $item['value'] == $entity->{$this->field_name}[$langcode][$delta]['value']; } - $this->assertTrue($result, $langcode . ' translation correctly handled.'); + $this->assertTrue($result, t('%language translation correctly handled.', array('%language' => $langcode))); } } @@ -2654,7 +2654,8 @@ class FieldTranslationsTestCase extends FieldTestCase { // Index 0 is reserved for the requested language, this way we ensure // that no field is actually populated with it. $langcode = $enabled_languages[mt_rand(1, count($enabled_languages) - 1)]; - } while (isset($languages[$langcode])); + } + while (isset($languages[$langcode])); $languages[$langcode] = TRUE; $entity->{$field_name}[$langcode] = $this->_generateTestFieldValues($field['cardinality']); } @@ -2666,7 +2667,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $display_language = field_language($entity_type, $entity, NULL, $requested_language); foreach ($instances as $instance) { $field_name = $instance['field_name']; - $this->assertTrue($display_language[$field_name] == LANGUAGE_NONE, 'The display language for field ' . $field_name . ' is ' . LANGUAGE_NONE . '.'); + $this->assertTrue($display_language[$field_name] == LANGUAGE_NONE, t('The display language for field %field_name is %language.', array('%field_name' => $field_name, '%language' => LANGUAGE_NONE))); } // Test multiple-fields display languages for translatable entities. @@ -2680,13 +2681,13 @@ class FieldTranslationsTestCase extends FieldTestCase { // As the requested language was not assinged to any field, if the // returned language is defined for the current field, core fallback rules // were successfully applied. - $this->assertTrue(isset($entity->{$field_name}[$langcode]) && $langcode != $requested_language, 'The display language for the field ' . $field_name . ' is ' . $langcode . '.'); + $this->assertTrue(isset($entity->{$field_name}[$langcode]) && $langcode != $requested_language, t('The display language for the field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); } // Test single-field display language. drupal_static_reset('field_language'); $langcode = field_language($entity_type, $entity, $this->field_name, $requested_language); - $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_language, 'The display language for the (single) field ' . $field_name . ' is ' . $langcode . '.'); + $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_language, t('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode))); } /** @@ -2730,7 +2731,7 @@ class FieldTranslationsTestCase extends FieldTestCase { $entity = field_test_entity_test_load($eid, $evid); foreach ($available_languages as $langcode => $value) { $passed = isset($entity->{$field_name}[$langcode]) && $entity->{$field_name}[$langcode][0]['value'] == $value + 1; - $this->assertTrue($passed, 'The ' . $langcode . ' translation for revision ' . $entity->ftvid . ' was correctly stored'); + $this->assertTrue($passed, t('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->ftvid))); } } } @@ -2744,7 +2745,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase { public static function getInfo() { return array( 'name' => 'Field bulk delete tests', - 'description' => 'Bulk delete fields and instances, and clean up afterwards.', + 'description'=> 'Bulk delete fields and instances, and clean up afterwards.', 'group' => 'Field API', ); } @@ -2925,7 +2926,7 @@ class FieldBulkDeleteTestCase extends FieldTestCase { $this->assertEqual($stubs[$entity->ftid], $entity, 'hook_field_delete() called with the correct stub'); unset($stubs[$entity->ftid]); } - $this->assertEqual(count($stubs), $count -10, 'hook_field_delete was called with each entity once'); + $this->assertEqual(count($stubs), $count-10, 'hook_field_delete was called with each entity once'); // The instance still exists, deleted. $instances = field_read_instances(array('field_id' => $field['id'], 'deleted' => 1), array('include_deleted' => 1, 'include_inactive' => 1)); |