Issue #1797106 by dcam, izus, xjm, lazysoundsystem, zuuperman, Lars Toomre: Remove t() from test asserts in field module

merge-requests/26/head
Jennifer Hodgdon 2013-04-26 08:33:35 -07:00
parent a71b5298c6
commit 6c7540d48a
6 changed files with 301 additions and 301 deletions

View File

@ -126,7 +126,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
foreach ($values as $delta => $value) { foreach ($values as $delta => $value) {
if ($delta < $this->field['cardinality']) { if ($delta < $this->field['cardinality']) {
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Value $delta is inserted correctly")); $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], format_string("Value %delta is inserted correctly", array('%delta' => $delta)));
} }
else { else {
$this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets inserted."); $this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets inserted.");
@ -145,7 +145,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
foreach ($values as $delta => $value) { foreach ($values as $delta => $value) {
if ($delta < $this->field['cardinality']) { if ($delta < $this->field['cardinality']) {
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Value $delta is updated correctly")); $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], format_string("Value %delta is updated correctly", array('%delta' => $delta)));
} }
else { else {
$this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets updated."); $this->assertFalse(array_key_exists($delta, $rows), "No extraneous value gets updated.");
@ -175,7 +175,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
foreach ($values as $delta => $value) { foreach ($values as $delta => $value) {
if ($delta < $this->field['cardinality']) { if ($delta < $this->field['cardinality']) {
$this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], t("Update with no field_name entry leaves value $delta untouched")); $this->assertEqual($rows[$delta][$this->field_name . '_value'], $value['value'], format_string("Update with no field_name entry leaves value %delta untouched", array('%delta' => $delta)));
} }
} }
@ -183,7 +183,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$entity->{$this->field_name} = NULL; $entity->{$this->field_name} = NULL;
field_attach_update($entity_type, $entity); field_attach_update($entity_type, $entity);
$rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', PDO::FETCH_ASSOC);
$this->assertEqual(count($rows), 0, t("Update with an empty field_name entry empties the field.")); $this->assertEqual(count($rows), 0, "Update with an empty field_name entry empties the field.");
} }
/** /**
@ -326,7 +326,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
// Ensure that the field tables are still there. // Ensure that the field tables are still there.
foreach (_field_sql_storage_schema($prior_field) as $table_name => $table_info) { foreach (_field_sql_storage_schema($prior_field) as $table_name => $table_info) {
$this->assertTrue(db_table_exists($table_name), t('Table %table exists.', array('%table' => $table_name))); $this->assertTrue(db_table_exists($table_name), format_string('Table %table exists.', array('%table' => $table_name)));
} }
} }
@ -345,8 +345,8 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
// Verify the indexes we will create do not exist yet. // Verify the indexes we will create do not exist yet.
foreach ($tables as $table) { foreach ($tables as $table) {
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), t("No index named value exists in $table")); $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), format_string("No index named value exists in %table", array('%table' => $table)));
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), t("No index named value_format exists in $table")); $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), format_string("No index named value_format exists in %table", array('%table' => $table)));
} }
// Add data so the table cannot be dropped. // Add data so the table cannot be dropped.
@ -358,21 +358,21 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$field = array('field_name' => $field_name, 'indexes' => array('value' => array('value'))); $field = array('field_name' => $field_name, 'indexes' => array('value' => array('value')));
field_update_field($field); field_update_field($field);
foreach ($tables as $table) { foreach ($tables as $table) {
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in $table")); $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), format_string("Index on value created in %table", array('%table' => $table)));
} }
// Add a different index, removing the existing custom one. // Add a different index, removing the existing custom one.
$field = array('field_name' => $field_name, 'indexes' => array('value_format' => array('value', 'format'))); $field = array('field_name' => $field_name, 'indexes' => array('value_format' => array('value', 'format')));
field_update_field($field); field_update_field($field);
foreach ($tables as $table) { foreach ($tables as $table) {
$this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in $table")); $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), format_string("Index on value_format created in %table", array('%table' => $table)));
$this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in $table")); $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), format_string("Index on value removed in %table", array('%table' => $table)));
} }
// Verify that the tables were not dropped. // Verify that the tables were not dropped.
$entity = field_test_create_stub_entity(0, 0, $instance['bundle']); $entity = field_test_create_stub_entity(0, 0, $instance['bundle']);
field_attach_load('test_entity', array(0 => $entity)); field_attach_load('test_entity', array(0 => $entity));
$this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', t("Index changes performed without dropping the tables")); $this->assertEqual($entity->{$field_name}[LANGUAGE_NONE][0]['value'], 'field data', "Index changes performed without dropping the tables");
} }
/** /**
@ -387,19 +387,19 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
$instance = field_info_instance($this->instance['entity_type'], $this->instance['field_name'], $this->instance['bundle']); $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. // 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. // The SQL details are indexed by table name.
$details = $field['storage']['details']['sql']; $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($current, $details[FIELD_LOAD_CURRENT]), '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($revision, $details[FIELD_LOAD_REVISION]), 'Revision table name is available in the instance array.');
// Test current and revision storage details together because the columns // Test current and revision storage details together because the columns
// are the same. // are the same.
foreach ((array) $this->field['columns'] as $column_name => $attributes) { foreach ((array) $this->field['columns'] as $column_name => $attributes) {
$storage_column_name = _field_sql_storage_columnname($this->field['field_name'], $column_name); $storage_column_name = _field_sql_storage_columnname($this->field['field_name'], $column_name);
$this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $current))); $this->assertEqual($details[FIELD_LOAD_CURRENT][$current][$column_name], $storage_column_name, format_string('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $current)));
$this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, t('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $revision))); $this->assertEqual($details[FIELD_LOAD_REVISION][$revision][$column_name], $storage_column_name, format_string('Column name %value matches the definition in %bin.', array('%value' => $column_name, '%bin' => $revision)));
} }
} }
@ -414,14 +414,14 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
// Retrieve the field and instance with field_info and verify the foreign // Retrieve the field and instance with field_info and verify the foreign
// keys are in place. // keys are in place.
$field = field_info_field($field_name); $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']['table'], 'filter_format', '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']['columns']['format'], 'format', 'Foreign key column name preserved through CRUD');
// Now grab the SQL schema and verify that too. // Now grab the SQL schema and verify that too.
$schema = drupal_get_schema(_field_sql_storage_tablename($field)); $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")); $this->assertEqual(count($schema['foreign keys']), 1, "There is 1 foreign key in the schema");
$foreign_key = reset($schema['foreign keys']); $foreign_key = reset($schema['foreign keys']);
$filter_column = _field_sql_storage_columnname($field['field_name'], 'format'); $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['table'], 'filter_format', '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['columns'][$filter_column], 'format', 'Foreign key column name preserved in the schema');
} }
} }

View File

@ -51,9 +51,9 @@ class ListFieldTestCase extends FieldTestCase {
// All three options appear. // All three options appear.
$entity = field_test_create_stub_entity(); $entity = field_test_create_stub_entity();
$form = drupal_get_form('field_test_entity_form', $entity); $form = drupal_get_form('field_test_entity_form', $entity);
$this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists')); $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), 'Option 1 exists');
$this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists');
$this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 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 // Use one of the values in an actual entity, and check that this value
// cannot be removed from the list. // cannot be removed from the list.
@ -77,19 +77,19 @@ class ListFieldTestCase extends FieldTestCase {
field_update_field($this->field); field_update_field($this->field);
$entity = field_test_create_stub_entity(); $entity = field_test_create_stub_entity();
$form = drupal_get_form('field_test_entity_form', $entity); $form = drupal_get_form('field_test_entity_form', $entity);
$this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist')); $this->assertTrue(empty($form[$this->field_name][$langcode][1]), '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][2]), '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][3]), 'Option 3 does not exist');
// Completely new options appear. // Completely new options appear.
$this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty'); $this->field['settings']['allowed_values'] = array(10 => 'Update', 20 => 'Twenty');
field_update_field($this->field); field_update_field($this->field);
$form = drupal_get_form('field_test_entity_form', $entity); $form = drupal_get_form('field_test_entity_form', $entity);
$this->assertTrue(empty($form[$this->field_name][$langcode][1]), t('Option 1 does not exist')); $this->assertTrue(empty($form[$this->field_name][$langcode][1]), '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][2]), '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][3]), '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][10]), 'Option 10 exists');
$this->assertTrue(!empty($form[$this->field_name][$langcode][20]), t('Option 20 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. // Options are reset when a new field with the same name is created.
field_delete_field($this->field_name); field_delete_field($this->field_name);
@ -107,9 +107,9 @@ class ListFieldTestCase extends FieldTestCase {
$this->instance = field_create_instance($this->instance); $this->instance = field_create_instance($this->instance);
$entity = field_test_create_stub_entity(); $entity = field_test_create_stub_entity();
$form = drupal_get_form('field_test_entity_form', $entity); $form = drupal_get_form('field_test_entity_form', $entity);
$this->assertTrue(!empty($form[$this->field_name][$langcode][1]), t('Option 1 exists')); $this->assertTrue(!empty($form[$this->field_name][$langcode][1]), 'Option 1 exists');
$this->assertTrue(!empty($form[$this->field_name][$langcode][2]), t('Option 2 exists')); $this->assertTrue(!empty($form[$this->field_name][$langcode][2]), 'Option 2 exists');
$this->assertTrue(!empty($form[$this->field_name][$langcode][3]), t('Option 3 exists')); $this->assertTrue(!empty($form[$this->field_name][$langcode][3]), 'Option 3 exists');
} }
} }
@ -233,20 +233,20 @@ class ListFieldUITestCase extends FieldTestCase {
// Flat list of textual values. // Flat list of textual values.
$string = "Zero\nOne"; $string = "Zero\nOne";
$array = array('0' => 'Zero', '1' => 'One'); $array = array('0' => 'Zero', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.')); $this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.');
// Explicit integer keys. // Explicit integer keys.
$string = "0|Zero\n2|Two"; $string = "0|Zero\n2|Two";
$array = array('0' => 'Zero', '2' => 'Two'); $array = array('0' => 'Zero', '2' => 'Two');
$this->assertAllowedValuesInput($string, $array, t('Integer keys are accepted.')); $this->assertAllowedValuesInput($string, $array, 'Integer keys are accepted.');
// Check that values can be added and removed. // Check that values can be added and removed.
$string = "0|Zero\n1|One"; $string = "0|Zero\n1|One";
$array = array('0' => 'Zero', '1' => 'One'); $array = array('0' => 'Zero', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.')); $this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.');
// Non-integer keys. // Non-integer keys.
$this->assertAllowedValuesInput("1.1|One", 'keys must be integers', t('Non integer keys are rejected.')); $this->assertAllowedValuesInput("1.1|One", 'keys must be integers', 'Non integer keys are rejected.');
$this->assertAllowedValuesInput("abc|abc", 'keys must be integers', t('Non integer keys are rejected.')); $this->assertAllowedValuesInput("abc|abc", 'keys must be integers', 'Non integer keys are rejected.');
// Mixed list of keyed and unkeyed values. // Mixed list of keyed and unkeyed values.
$this->assertAllowedValuesInput("Zero\n1|One", 'invalid input', t('Mixed lists are rejected.')); $this->assertAllowedValuesInput("Zero\n1|One", 'invalid input', 'Mixed lists are rejected.');
// Create a node with actual data for the field. // Create a node with actual data for the field.
$settings = array( $settings = array(
@ -256,22 +256,22 @@ class ListFieldUITestCase extends FieldTestCase {
$node = $this->drupalCreateNode($settings); $node = $this->drupalCreateNode($settings);
// Check that a flat list of values is rejected once the field has data. // Check that a flat list of values is rejected once the field has data.
$this->assertAllowedValuesInput( "Zero\nOne", 'invalid input', t('Unkeyed lists are rejected once the field has data.')); $this->assertAllowedValuesInput( "Zero\nOne", 'invalid input', 'Unkeyed lists are rejected once the field has data.');
// Check that values can be added but values in use cannot be removed. // Check that values can be added but values in use cannot be removed.
$string = "0|Zero\n1|One\n2|Two"; $string = "0|Zero\n1|One\n2|Two";
$array = array('0' => 'Zero', '1' => 'One', '2' => 'Two'); $array = array('0' => 'Zero', '1' => 'One', '2' => 'Two');
$this->assertAllowedValuesInput($string, $array, t('Values can be added.')); $this->assertAllowedValuesInput($string, $array, 'Values can be added.');
$string = "0|Zero\n1|One"; $string = "0|Zero\n1|One";
$array = array('0' => 'Zero', '1' => 'One'); $array = array('0' => 'Zero', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.')); $this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.');
// Delete the node, remove the value. // Delete the node, remove the value.
node_delete($node->nid); node_delete($node->nid);
$string = "0|Zero"; $string = "0|Zero";
$array = array('0' => 'Zero'); $array = array('0' => 'Zero');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
} }
/** /**
@ -284,19 +284,19 @@ class ListFieldUITestCase extends FieldTestCase {
// Flat list of textual values. // Flat list of textual values.
$string = "Zero\nOne"; $string = "Zero\nOne";
$array = array('0' => 'Zero', '1' => 'One'); $array = array('0' => 'Zero', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.')); $this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.');
// Explicit numeric keys. // Explicit numeric keys.
$string = "0|Zero\n.5|Point five"; $string = "0|Zero\n.5|Point five";
$array = array('0' => 'Zero', '0.5' => 'Point five'); $array = array('0' => 'Zero', '0.5' => 'Point five');
$this->assertAllowedValuesInput($string, $array, t('Integer keys are accepted.')); $this->assertAllowedValuesInput($string, $array, 'Integer keys are accepted.');
// Check that values can be added and removed. // Check that values can be added and removed.
$string = "0|Zero\n.5|Point five\n1.0|One"; $string = "0|Zero\n.5|Point five\n1.0|One";
$array = array('0' => 'Zero', '0.5' => 'Point five', '1' => 'One'); $array = array('0' => 'Zero', '0.5' => 'Point five', '1' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.')); $this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.');
// Non-numeric keys. // Non-numeric keys.
$this->assertAllowedValuesInput("abc|abc\n", 'each key must be a valid integer or decimal', t('Non numeric keys are rejected.')); $this->assertAllowedValuesInput("abc|abc\n", 'each key must be a valid integer or decimal', 'Non numeric keys are rejected.');
// Mixed list of keyed and unkeyed values. // Mixed list of keyed and unkeyed values.
$this->assertAllowedValuesInput("Zero\n1|One\n", 'invalid input', t('Mixed lists are rejected.')); $this->assertAllowedValuesInput("Zero\n1|One\n", 'invalid input', 'Mixed lists are rejected.');
// Create a node with actual data for the field. // Create a node with actual data for the field.
$settings = array( $settings = array(
@ -306,22 +306,22 @@ class ListFieldUITestCase extends FieldTestCase {
$node = $this->drupalCreateNode($settings); $node = $this->drupalCreateNode($settings);
// Check that a flat list of values is rejected once the field has data. // Check that a flat list of values is rejected once the field has data.
$this->assertAllowedValuesInput("Zero\nOne", 'invalid input', t('Unkeyed lists are rejected once the field has data.')); $this->assertAllowedValuesInput("Zero\nOne", 'invalid input', 'Unkeyed lists are rejected once the field has data.');
// Check that values can be added but values in use cannot be removed. // Check that values can be added but values in use cannot be removed.
$string = "0|Zero\n.5|Point five\n2|Two"; $string = "0|Zero\n.5|Point five\n2|Two";
$array = array('0' => 'Zero', '0.5' => 'Point five', '2' => 'Two'); $array = array('0' => 'Zero', '0.5' => 'Point five', '2' => 'Two');
$this->assertAllowedValuesInput($string, $array, t('Values can be added.')); $this->assertAllowedValuesInput($string, $array, 'Values can be added.');
$string = "0|Zero\n.5|Point five"; $string = "0|Zero\n.5|Point five";
$array = array('0' => 'Zero', '0.5' => 'Point five'); $array = array('0' => 'Zero', '0.5' => 'Point five');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
$this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.')); $this->assertAllowedValuesInput("0|Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.');
// Delete the node, remove the value. // Delete the node, remove the value.
node_delete($node->nid); node_delete($node->nid);
$string = "0|Zero"; $string = "0|Zero";
$array = array('0' => 'Zero'); $array = array('0' => 'Zero');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
} }
/** /**
@ -334,21 +334,21 @@ class ListFieldUITestCase extends FieldTestCase {
// Flat list of textual values. // Flat list of textual values.
$string = "Zero\nOne"; $string = "Zero\nOne";
$array = array('Zero' => 'Zero', 'One' => 'One'); $array = array('Zero' => 'Zero', 'One' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are accepted.')); $this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are accepted.');
// Explicit keys. // Explicit keys.
$string = "zero|Zero\none|One"; $string = "zero|Zero\none|One";
$array = array('zero' => 'Zero', 'one' => 'One'); $array = array('zero' => 'Zero', 'one' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Explicit keys are accepted.')); $this->assertAllowedValuesInput($string, $array, 'Explicit keys are accepted.');
// Check that values can be added and removed. // Check that values can be added and removed.
$string = "zero|Zero\ntwo|Two"; $string = "zero|Zero\ntwo|Two";
$array = array('zero' => 'Zero', 'two' => 'Two'); $array = array('zero' => 'Zero', 'two' => 'Two');
$this->assertAllowedValuesInput($string, $array, t('Values can be added and removed.')); $this->assertAllowedValuesInput($string, $array, 'Values can be added and removed.');
// Mixed list of keyed and unkeyed values. // Mixed list of keyed and unkeyed values.
$string = "zero|Zero\nOne\n"; $string = "zero|Zero\nOne\n";
$array = array('zero' => 'Zero', 'One' => 'One'); $array = array('zero' => 'Zero', 'One' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Mixed lists are accepted.')); $this->assertAllowedValuesInput($string, $array, 'Mixed lists are accepted.');
// Overly long keys. // Overly long keys.
$this->assertAllowedValuesInput("zero|Zero\n" . $this->randomName(256) . "|One", 'each key must be a string at most 255 characters long', t('Overly long keys are rejected.')); $this->assertAllowedValuesInput("zero|Zero\n" . $this->randomName(256) . "|One", 'each key must be a string at most 255 characters long', 'Overly long keys are rejected.');
// Create a node with actual data for the field. // Create a node with actual data for the field.
$settings = array( $settings = array(
@ -361,22 +361,22 @@ class ListFieldUITestCase extends FieldTestCase {
// data. // data.
$string = "Zero\nOne"; $string = "Zero\nOne";
$array = array('Zero' => 'Zero', 'One' => 'One'); $array = array('Zero' => 'Zero', 'One' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Unkeyed lists are still accepted once the field has data.')); $this->assertAllowedValuesInput($string, $array, 'Unkeyed lists are still accepted once the field has data.');
// Check that values can be added but values in use cannot be removed. // Check that values can be added but values in use cannot be removed.
$string = "Zero\nOne\nTwo"; $string = "Zero\nOne\nTwo";
$array = array('Zero' => 'Zero', 'One' => 'One', 'Two' => 'Two'); $array = array('Zero' => 'Zero', 'One' => 'One', 'Two' => 'Two');
$this->assertAllowedValuesInput($string, $array, t('Values can be added.')); $this->assertAllowedValuesInput($string, $array, 'Values can be added.');
$string = "Zero\nOne"; $string = "Zero\nOne";
$array = array('Zero' => 'Zero', 'One' => 'One'); $array = array('Zero' => 'Zero', 'One' => 'One');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
$this->assertAllowedValuesInput("Zero", 'some values are being removed while currently in use', t('Values in use cannot be removed.')); $this->assertAllowedValuesInput("Zero", 'some values are being removed while currently in use', 'Values in use cannot be removed.');
// Delete the node, remove the value. // Delete the node, remove the value.
node_delete($node->nid); node_delete($node->nid);
$string = "Zero"; $string = "Zero";
$array = array('Zero' => 'Zero'); $array = array('Zero' => 'Zero');
$this->assertAllowedValuesInput($string, $array, t('Values not in use can be removed.')); $this->assertAllowedValuesInput($string, $array, 'Values not in use can be removed.');
} }
/** /**
@ -395,15 +395,15 @@ class ListFieldUITestCase extends FieldTestCase {
'off' => $off, 'off' => $off,
); );
$this->drupalPost($this->admin_path, $edit, t('Save settings')); $this->drupalPost($this->admin_path, $edit, t('Save settings'));
$this->assertText("Saved field_list_boolean configuration.", t("The 'On' and 'Off' form fields work for boolean fields.")); $this->assertText("Saved field_list_boolean configuration.", "The 'On' and 'Off' form fields work for boolean fields.");
// Test the allowed_values on the field settings form. // Test the allowed_values on the field settings form.
$this->drupalGet($this->admin_path); $this->drupalGet($this->admin_path);
$this->assertFieldByName('on', $on, t("The 'On' value is stored correctly.")); $this->assertFieldByName('on', $on, "The 'On' value is stored correctly.");
$this->assertFieldByName('off', $off, t("The 'Off' value is stored correctly.")); $this->assertFieldByName('off', $off, "The 'Off' value is stored correctly.");
$field = field_info_field($this->field_name); $field = field_info_field($this->field_name);
$this->assertEqual($field['settings']['allowed_values'], $allowed_values, t('The allowed value is correct')); $this->assertEqual($field['settings']['allowed_values'], $allowed_values, 'The allowed value is correct');
$this->assertFalse(isset($field['settings']['on']), t('The on value is not saved into settings')); $this->assertFalse(isset($field['settings']['on']), 'The on value is not saved into settings');
$this->assertFalse(isset($field['settings']['off']), t('The off value is not saved into settings')); $this->assertFalse(isset($field['settings']['off']), 'The off value is not saved into settings');
} }
/** /**

View File

@ -58,7 +58,7 @@ class NumberFieldTestCase extends DrupalWebTestCase {
// Display creation form. // Display creation form.
$this->drupalGet('test-entity/add/test-bundle'); $this->drupalGet('test-entity/add/test-bundle');
$langcode = LANGUAGE_NONE; $langcode = LANGUAGE_NONE;
$this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', t('Widget is displayed')); $this->assertFieldByName("{$this->field['field_name']}[$langcode][0][value]", '', 'Widget is displayed');
// Submit a signed decimal value within the allowed precision and scale. // Submit a signed decimal value within the allowed precision and scale.
$value = '-1234.5678'; $value = '-1234.5678';
@ -68,8 +68,8 @@ class NumberFieldTestCase extends DrupalWebTestCase {
$this->drupalPost(NULL, $edit, t('Save')); $this->drupalPost(NULL, $edit, t('Save'));
preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match);
$id = $match[1]; $id = $match[1];
$this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created')); $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created');
$this->assertRaw(round($value, 2), t('Value is displayed.')); $this->assertRaw(round($value, 2), 'Value is displayed.');
// Try to create entries with more than one decimal separator; assert fail. // Try to create entries with more than one decimal separator; assert fail.
$wrong_entries = array( $wrong_entries = array(
@ -89,7 +89,7 @@ class NumberFieldTestCase extends DrupalWebTestCase {
$this->assertText( $this->assertText(
t('There should only be one decimal separator (@separator)', t('There should only be one decimal separator (@separator)',
array('@separator' => $this->field['settings']['decimal_separator'])), array('@separator' => $this->field['settings']['decimal_separator'])),
t('Correctly failed to save decimal value with more than one decimal point.') 'Correctly failed to save decimal value with more than one decimal point.'
); );
} }

View File

@ -85,7 +85,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$this->assertNoFieldChecked("edit-card-1-$langcode-0"); $this->assertNoFieldChecked("edit-card-1-$langcode-0");
$this->assertNoFieldChecked("edit-card-1-$langcode-1"); $this->assertNoFieldChecked("edit-card-1-$langcode-1");
$this->assertNoFieldChecked("edit-card-1-$langcode-2"); $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. // Select first option.
$edit = array("card_1[$langcode]" => 0); $edit = array("card_1[$langcode]" => 0);
@ -139,7 +139,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$this->assertNoFieldChecked("edit-card-2-$langcode-0"); $this->assertNoFieldChecked("edit-card-2-$langcode-0");
$this->assertNoFieldChecked("edit-card-2-$langcode-1"); $this->assertNoFieldChecked("edit-card-2-$langcode-1");
$this->assertNoFieldChecked("edit-card-2-$langcode-2"); $this->assertNoFieldChecked("edit-card-2-$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.');
// Submit form: select first and third options. // Submit form: select first and third options.
$edit = array( $edit = array(
@ -178,7 +178,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
"card_2[$langcode][2]" => TRUE, "card_2[$langcode][2]" => TRUE,
); );
$this->drupalPost(NULL, $edit, t('Save')); $this->drupalPost(NULL, $edit, t('Save'));
$this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.')); $this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.');
// Submit form: uncheck all options. // Submit form: uncheck all options.
$edit = array( $edit = array(
@ -225,19 +225,19 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Display form. // Display form.
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
// A required field without any value has a "none" option. // A required field without any value has a "none" option.
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- Select a value -'))), t('A required select list has a "Select a value" choice.')); $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- Select a value -'))), 'A required select list has a "Select a value" choice.');
// With no field data, nothing is selected. // With no field data, nothing is selected.
$this->assertNoOptionSelected("edit-card-1-$langcode", '_none'); $this->assertNoOptionSelected("edit-card-1-$langcode", '_none');
$this->assertNoOptionSelected("edit-card-1-$langcode", 0); $this->assertNoOptionSelected("edit-card-1-$langcode", 0);
$this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 1);
$this->assertNoOptionSelected("edit-card-1-$langcode", 2); $this->assertNoOptionSelected("edit-card-1-$langcode", 2);
$this->assertRaw('Some dangerous &amp; unescaped markup', t('Option text was properly filtered.')); $this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
// Submit form: select invalid 'none' option. // Submit form: select invalid 'none' option.
$edit = array("card_1[$langcode]" => '_none'); $edit = array("card_1[$langcode]" => '_none');
$this->drupalPost(NULL, $edit, t('Save')); $this->drupalPost(NULL, $edit, t('Save'));
$this->assertRaw(t('!title field is required.', array('!title' => $instance['field_name'])), t('Cannot save a required field when selecting "none" from the select list.')); $this->assertRaw(t('!title field is required.', array('!title' => $instance['field_name'])), 'Cannot save a required field when selecting "none" from the select list.');
// Submit form: select first option. // Submit form: select first option.
$edit = array("card_1[$langcode]" => 0); $edit = array("card_1[$langcode]" => 0);
@ -247,7 +247,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Display form: check that the right options are selected. // Display form: check that the right options are selected.
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
// A required field with a value has no 'none' option. // A required field with a value has no 'none' option.
$this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1-' . $langcode)), t('A required select list with an actual value has no "none" choice.')); $this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', array(':id' => 'edit-card-1-' . $langcode)), 'A required select list with an actual value has no "none" choice.');
$this->assertOptionSelected("edit-card-1-$langcode", 0); $this->assertOptionSelected("edit-card-1-$langcode", 0);
$this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 1);
$this->assertNoOptionSelected("edit-card-1-$langcode", 2); $this->assertNoOptionSelected("edit-card-1-$langcode", 2);
@ -259,7 +259,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Display form. // Display form.
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
// A non-required field has a 'none' option. // A non-required field has a 'none' option.
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- None -'))), t('A non-required select list has a "None" choice.')); $this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', array(':id' => 'edit-card-1-' . $langcode, ':label' => t('- None -'))), 'A non-required select list has a "None" choice.');
// Submit form: Unselect the option. // Submit form: Unselect the option.
$edit = array("card_1[$langcode]" => '_none'); $edit = array("card_1[$langcode]" => '_none');
$this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save')); $this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save'));
@ -276,8 +276,8 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$this->assertNoOptionSelected("edit-card-1-$langcode", 0); $this->assertNoOptionSelected("edit-card-1-$langcode", 0);
$this->assertNoOptionSelected("edit-card-1-$langcode", 1); $this->assertNoOptionSelected("edit-card-1-$langcode", 1);
$this->assertNoOptionSelected("edit-card-1-$langcode", 2); $this->assertNoOptionSelected("edit-card-1-$langcode", 2);
$this->assertRaw('Some dangerous &amp; unescaped markup', t('Option text was properly filtered.')); $this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
$this->assertRaw('Group 1', t('Option groups are displayed.')); $this->assertRaw('Group 1', 'Option groups are displayed.');
// Submit form: select first option. // Submit form: select first option.
$edit = array("card_1[$langcode]" => 0); $edit = array("card_1[$langcode]" => 0);
@ -323,7 +323,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$this->assertNoOptionSelected("edit-card-2-$langcode", 0); $this->assertNoOptionSelected("edit-card-2-$langcode", 0);
$this->assertNoOptionSelected("edit-card-2-$langcode", 1); $this->assertNoOptionSelected("edit-card-2-$langcode", 1);
$this->assertNoOptionSelected("edit-card-2-$langcode", 2); $this->assertNoOptionSelected("edit-card-2-$langcode", 2);
$this->assertRaw('Some dangerous &amp; unescaped markup', t('Option text was properly filtered.')); $this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
// Submit form: select first and third options. // Submit form: select first and third options.
$edit = array("card_2[$langcode][]" => array(0 => 0, 2 => 2)); $edit = array("card_2[$langcode][]" => array(0 => 0, 2 => 2));
@ -350,7 +350,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Submit form: select the three options while the field accepts only 2. // Submit form: select the three options while the field accepts only 2.
$edit = array("card_2[$langcode][]" => array(0 => 0, 1 => 1, 2 => 2)); $edit = array("card_2[$langcode][]" => array(0 => 0, 1 => 1, 2 => 2));
$this->drupalPost(NULL, $edit, t('Save')); $this->drupalPost(NULL, $edit, t('Save'));
$this->assertText('this field cannot hold more than 2 values', t('Validation error was displayed.')); $this->assertText('this field cannot hold more than 2 values', 'Validation error was displayed.');
// Submit form: uncheck all options. // Submit form: uncheck all options.
$edit = array("card_2[$langcode][]" => array()); $edit = array("card_2[$langcode][]" => array());
@ -374,7 +374,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$instance['required'] = TRUE; $instance['required'] = TRUE;
field_update_instance($instance); field_update_instance($instance);
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
$this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), t('A required select list does not have an empty key.')); $this->assertFalse($this->xpath('//select[@id=:id]//option[@value=""]', array(':id' => 'edit-card-2-' . $langcode)), 'A required select list does not have an empty key.');
// We do not have to test that a required select list with one option is // We do not have to test that a required select list with one option is
// auto-selected because the browser does it for us. // auto-selected because the browser does it for us.
@ -393,8 +393,8 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$this->assertNoOptionSelected("edit-card-2-$langcode", 0); $this->assertNoOptionSelected("edit-card-2-$langcode", 0);
$this->assertNoOptionSelected("edit-card-2-$langcode", 1); $this->assertNoOptionSelected("edit-card-2-$langcode", 1);
$this->assertNoOptionSelected("edit-card-2-$langcode", 2); $this->assertNoOptionSelected("edit-card-2-$langcode", 2);
$this->assertRaw('Some dangerous &amp; unescaped markup', t('Option text was properly filtered.')); $this->assertRaw('Some dangerous &amp; unescaped markup', 'Option text was properly filtered.');
$this->assertRaw('Group 1', t('Option groups are displayed.')); $this->assertRaw('Group 1', 'Option groups are displayed.');
// Submit form: select first option. // Submit form: select first option.
$edit = array("card_2[$langcode][]" => array(0 => 0)); $edit = array("card_2[$langcode][]" => array(0 => 0));
@ -438,7 +438,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
// Display form: with no field data, option is unchecked. // Display form: with no field data, option is unchecked.
$this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit'); $this->drupalGet('test-entity/manage/' . $entity->ftid . '/edit');
$this->assertNoFieldChecked("edit-bool-$langcode"); $this->assertNoFieldChecked("edit-bool-$langcode");
$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.');
// Submit form: check the option. // Submit form: check the option.
$edit = array("bool[$langcode]" => TRUE); $edit = array("bool[$langcode]" => TRUE);
@ -483,13 +483,13 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$this->assertText( $this->assertText(
'Use field label instead of the "On value" as label ', 'Use field label instead of the "On value" as label ',
t('Display setting checkbox available.') 'Display setting checkbox available.'
); );
$this->assertFieldByXPath( $this->assertFieldByXPath(
'*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="MyOnValue "]', '*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="MyOnValue "]',
TRUE, TRUE,
t('Default case shows "On value"') 'Default case shows "On value"'
); );
// Enable setting // Enable setting
@ -502,16 +502,16 @@ class OptionsWidgetsTestCase extends FieldTestCase {
$this->drupalGet($fieldEditUrl); $this->drupalGet($fieldEditUrl);
$this->assertText( $this->assertText(
'Use field label instead of the "On value" as label ', 'Use field label instead of the "On value" as label ',
t('Display setting checkbox is available') 'Display setting checkbox is available'
); );
$this->assertFieldChecked( $this->assertFieldChecked(
'edit-instance-widget-settings-display-label', 'edit-instance-widget-settings-display-label',
t('Display settings checkbox checked') 'Display settings checkbox checked'
); );
$this->assertFieldByXPath( $this->assertFieldByXPath(
'*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="' . $this->bool['field_name'] . ' "]', '*//label[@for="edit-' . $this->bool['field_name'] . '-und" and text()="' . $this->bool['field_name'] . ' "]',
TRUE, TRUE,
t('Display label changes label of the checkbox') 'Display label changes label of the checkbox'
); );
} }
} }

View File

@ -110,8 +110,8 @@ class TextFieldTestCase extends DrupalWebTestCase {
// Display creation form. // Display creation form.
$this->drupalGet('test-entity/add/test-bundle'); $this->drupalGet('test-entity/add/test-bundle');
$this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed')); $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed');
$this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', t('Format selector is not displayed')); $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', 'Format selector is not displayed');
// Submit with some value. // Submit with some value.
$value = $this->randomName(); $value = $this->randomName();
@ -121,7 +121,7 @@ class TextFieldTestCase extends DrupalWebTestCase {
$this->drupalPost(NULL, $edit, t('Save')); $this->drupalPost(NULL, $edit, t('Save'));
preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match);
$id = $match[1]; $id = $match[1];
$this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created')); $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created');
// Display the entity. // Display the entity.
$entity = field_test_entity_test_load($id); $entity = field_test_entity_test_load($id);
@ -179,8 +179,8 @@ class TextFieldTestCase extends DrupalWebTestCase {
// Display the creation form. Since the user only has access to one format, // Display the creation form. Since the user only has access to one format,
// no format selector will be displayed. // no format selector will be displayed.
$this->drupalGet('test-entity/add/test-bundle'); $this->drupalGet('test-entity/add/test-bundle');
$this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', t('Widget is displayed')); $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", '', 'Widget is displayed');
$this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is not displayed')); $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', 'Format selector is not displayed');
// Submit with data that should be filtered. // Submit with data that should be filtered.
$value = '<em>' . $this->randomName() . '</em>'; $value = '<em>' . $this->randomName() . '</em>';
@ -190,14 +190,14 @@ class TextFieldTestCase extends DrupalWebTestCase {
$this->drupalPost(NULL, $edit, t('Save')); $this->drupalPost(NULL, $edit, t('Save'));
preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match); preg_match('|test-entity/manage/(\d+)/edit|', $this->url, $match);
$id = $match[1]; $id = $match[1];
$this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), t('Entity was created')); $this->assertRaw(t('test_entity @id has been created.', array('@id' => $id)), 'Entity was created');
// Display the entity. // Display the entity.
$entity = field_test_entity_test_load($id); $entity = field_test_entity_test_load($id);
$entity->content = field_attach_view($entity_type, $entity, 'full'); $entity->content = field_attach_view($entity_type, $entity, 'full');
$this->content = drupal_render($entity->content); $this->content = drupal_render($entity->content);
$this->assertNoRaw($value, t('HTML tags are not displayed.')); $this->assertNoRaw($value, 'HTML tags are not displayed.');
$this->assertRaw(check_plain($value), t('Escaped HTML is displayed correctly.')); $this->assertRaw(check_plain($value), 'Escaped HTML is displayed correctly.');
// Create a new text format that does not escape HTML, and grant the user // Create a new text format that does not escape HTML, and grant the user
// access to it. // access to it.
@ -219,21 +219,21 @@ class TextFieldTestCase extends DrupalWebTestCase {
// Display edition form. // Display edition form.
// We should now have a 'text format' selector. // We should now have a 'text format' selector.
$this->drupalGet('test-entity/manage/' . $id . '/edit'); $this->drupalGet('test-entity/manage/' . $id . '/edit');
$this->assertFieldByName("{$this->field_name}[$langcode][0][value]", NULL, t('Widget is displayed')); $this->assertFieldByName("{$this->field_name}[$langcode][0][value]", NULL, 'Widget is displayed');
$this->assertFieldByName("{$this->field_name}[$langcode][0][format]", NULL, t('Format selector is displayed')); $this->assertFieldByName("{$this->field_name}[$langcode][0][format]", NULL, 'Format selector is displayed');
// Edit and change the text format to the new one that was created. // Edit and change the text format to the new one that was created.
$edit = array( $edit = array(
"{$this->field_name}[$langcode][0][format]" => $format_id, "{$this->field_name}[$langcode][0][format]" => $format_id,
); );
$this->drupalPost(NULL, $edit, t('Save')); $this->drupalPost(NULL, $edit, t('Save'));
$this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), t('Entity was updated')); $this->assertRaw(t('test_entity @id has been updated.', array('@id' => $id)), 'Entity was updated');
// Display the entity. // Display the entity.
$entity = field_test_entity_test_load($id); $entity = field_test_entity_test_load($id);
$entity->content = field_attach_view($entity_type, $entity, 'full'); $entity->content = field_attach_view($entity_type, $entity, 'full');
$this->content = drupal_render($entity->content); $this->content = drupal_render($entity->content);
$this->assertRaw($value, t('Value is displayed unfiltered')); $this->assertRaw($value, 'Value is displayed unfiltered');
} }
} }
@ -383,7 +383,7 @@ class TextSummaryTestCase extends DrupalWebTestCase {
*/ */
function callTextSummary($text, $expected, $format = NULL, $size = NULL) { function callTextSummary($text, $expected, $format = NULL, $size = NULL) {
$summary = text_summary($text, $format, $size); $summary = text_summary($text, $format, $size);
$this->assertIdentical($summary, $expected, t('Generated summary "@summary" matches expected "@expected".', array('@summary' => $summary, '@expected' => $expected))); $this->assertIdentical($summary, $expected, format_string('Generated summary "@summary" matches expected "@expected".', array('@summary' => $summary, '@expected' => $expected)));
} }
/** /**
@ -401,7 +401,7 @@ class TextSummaryTestCase extends DrupalWebTestCase {
$this->drupalPost('node/add/article', $edit, t('Save')); $this->drupalPost('node/add/article', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit['title']); $node = $this->drupalGetNodeByTitle($edit['title']);
$this->assertIdentical($node->body['und'][0]['summary'], $summary, t('Article with with summary and no body has been submitted.')); $this->assertIdentical($node->body['und'][0]['summary'], $summary, 'Article with with summary and no body has been submitted.');
} }
} }
@ -436,7 +436,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
// Set "Article" content type to use multilingual support with translation. // Set "Article" content type to use multilingual support with translation.
$edit = array('language_content_type' => 2); $edit = array('language_content_type' => 2);
$this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));
$this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), t('Article content type has been updated.')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), 'Article content type has been updated.');
} }
/** /**
@ -464,7 +464,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
$node = $this->drupalGetNodeByTitle($edit['title']); $node = $this->drupalGetNodeByTitle($edit['title']);
$this->drupalGet("node/$node->nid/translate"); $this->drupalGet("node/$node->nid/translate");
$this->clickLink(t('add translation')); $this->clickLink(t('add translation'));
$this->assertFieldByXPath("//textarea[@name='body[$langcode][0][value]']", $body, t('The textfield widget is populated.')); $this->assertFieldByXPath("//textarea[@name='body[$langcode][0][value]']", $body, 'The textfield widget is populated.');
} }
/** /**
@ -476,7 +476,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
$edit = array('field[cardinality]' => -1); $edit = array('field[cardinality]' => -1);
$this->drupalPost('admin/structure/types/manage/article/fields/body', $edit, t('Save settings')); $this->drupalPost('admin/structure/types/manage/article/fields/body', $edit, t('Save settings'));
$this->drupalGet('node/add/article'); $this->drupalGet('node/add/article');
$this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), t('Body field cardinality set to multiple.')); $this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), 'Body field cardinality set to multiple.');
$body = array( $body = array(
$this->randomName(), $this->randomName(),
@ -501,7 +501,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
"body[$langcode][$delta][format]" => array_shift($formats), "body[$langcode][$delta][format]" => array_shift($formats),
); );
$this->drupalPost('node/1/edit', $edit, t('Save')); $this->drupalPost('node/1/edit', $edit, t('Save'));
$this->assertText($body[$delta], t('The body field with delta @delta has been saved.', array('@delta' => $delta))); $this->assertText($body[$delta], format_string('The body field with delta @delta has been saved.', array('@delta' => $delta)));
} }
// Login as translator. // Login as translator.
@ -511,7 +511,7 @@ class TextTranslationTestCase extends DrupalWebTestCase {
$node = $this->drupalGetNodeByTitle($title); $node = $this->drupalGetNodeByTitle($title);
$this->drupalGet("node/$node->nid/translate"); $this->drupalGet("node/$node->nid/translate");
$this->clickLink(t('add translation')); $this->clickLink(t('add translation'));
$this->assertNoText($body[0], t('The body field with delta @delta is hidden.', array('@delta' => 0))); $this->assertNoText($body[0], format_string('The body field with delta @delta is hidden.', array('@delta' => 0)));
$this->assertText($body[1], t('The body field with delta @delta is shown.', array('@delta' => 1))); $this->assertText($body[1], format_string('The body field with delta @delta is shown.', array('@delta' => 1)));
} }
} }

File diff suppressed because it is too large Load Diff