diff options
author | Jennifer Hodgdon <yahgrp@poplarware.com> | 2013-04-26 08:29:17 -0700 |
---|---|---|
committer | Jennifer Hodgdon <yahgrp@poplarware.com> | 2013-04-26 08:29:17 -0700 |
commit | a71b5298c6f88694953924443477c6edd0c29efb (patch) | |
tree | fe46372ed8777508531c5b447d5f46e7e22b95f2 | |
parent | dd4979eb9c9fa0eb270d359255be868afc22fff3 (diff) | |
download | brdo-a71b5298c6f88694953924443477c6edd0c29efb.tar.gz brdo-a71b5298c6f88694953924443477c6edd0c29efb.tar.bz2 |
Issue #1797272 by dcam, izus, xjm, Lars Toomre: Remove t() from test asserts in filter module
-rw-r--r-- | modules/filter/filter.test | 424 |
1 files changed, 212 insertions, 212 deletions
diff --git a/modules/filter/filter.test b/modules/filter/filter.test index 0c3949517..cc0295b59 100644 --- a/modules/filter/filter.test +++ b/modules/filter/filter.test @@ -67,9 +67,9 @@ class FilterCRUDTestCase extends DrupalWebTestCase { filter_format_disable($format); $db_format = db_query("SELECT * FROM {filter_format} WHERE format = :format", array(':format' => $format->format))->fetchObject(); - $this->assertFalse($db_format->status, t('Database: Disabled text format is marked as disabled.')); + $this->assertFalse($db_format->status, 'Database: Disabled text format is marked as disabled.'); $formats = filter_formats(); - $this->assertTrue(!isset($formats[$format->format]), t('filter_formats: Disabled text format no longer exists.')); + $this->assertTrue(!isset($formats[$format->format]), 'filter_formats: Disabled text format no longer exists.'); } /** @@ -83,17 +83,17 @@ class FilterCRUDTestCase extends DrupalWebTestCase { ->condition('format', $format->format) ->execute() ->fetchObject(); - $this->assertEqual($db_format->format, $format->format, t('Database: Proper format id for text format %format.', $t_args)); - $this->assertEqual($db_format->name, $format->name, t('Database: Proper title for text format %format.', $t_args)); - $this->assertEqual($db_format->cache, $format->cache, t('Database: Proper cache indicator for text format %format.', $t_args)); - $this->assertEqual($db_format->weight, $format->weight, t('Database: Proper weight for text format %format.', $t_args)); + $this->assertEqual($db_format->format, $format->format, format_string('Database: Proper format id for text format %format.', $t_args)); + $this->assertEqual($db_format->name, $format->name, format_string('Database: Proper title for text format %format.', $t_args)); + $this->assertEqual($db_format->cache, $format->cache, format_string('Database: Proper cache indicator for text format %format.', $t_args)); + $this->assertEqual($db_format->weight, $format->weight, format_string('Database: Proper weight for text format %format.', $t_args)); // Verify filter_format_load(). $filter_format = filter_format_load($format->format); - $this->assertEqual($filter_format->format, $format->format, t('filter_format_load: Proper format id for text format %format.', $t_args)); - $this->assertEqual($filter_format->name, $format->name, t('filter_format_load: Proper title for text format %format.', $t_args)); - $this->assertEqual($filter_format->cache, $format->cache, t('filter_format_load: Proper cache indicator for text format %format.', $t_args)); - $this->assertEqual($filter_format->weight, $format->weight, t('filter_format_load: Proper weight for text format %format.', $t_args)); + $this->assertEqual($filter_format->format, $format->format, format_string('filter_format_load: Proper format id for text format %format.', $t_args)); + $this->assertEqual($filter_format->name, $format->name, format_string('filter_format_load: Proper title for text format %format.', $t_args)); + $this->assertEqual($filter_format->cache, $format->cache, format_string('filter_format_load: Proper cache indicator for text format %format.', $t_args)); + $this->assertEqual($filter_format->weight, $format->weight, format_string('filter_format_load: Proper weight for text format %format.', $t_args)); // Verify the 'cache' text format property according to enabled filters. $filter_info = filter_get_filters(); @@ -107,7 +107,7 @@ class FilterCRUDTestCase extends DrupalWebTestCase { break; } } - $this->assertEqual($filter_format->cache, $cacheable, t('Text format contains proper cache property.')); + $this->assertEqual($filter_format->cache, $cacheable, 'Text format contains proper cache property.'); } /** @@ -121,20 +121,20 @@ class FilterCRUDTestCase extends DrupalWebTestCase { $t_args = array('%format' => $format->name, '%filter' => $name); // Verify that filter status is properly stored. - $this->assertEqual($filter->status, $format_filters[$name]['status'], t('Database: Proper status for %filter in text format %format.', $t_args)); + $this->assertEqual($filter->status, $format_filters[$name]['status'], format_string('Database: Proper status for %filter in text format %format.', $t_args)); // Verify that filter settings were properly stored. - $this->assertEqual(unserialize($filter->settings), isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), t('Database: Proper filter settings for %filter in text format %format.', $t_args)); + $this->assertEqual(unserialize($filter->settings), isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), format_string('Database: Proper filter settings for %filter in text format %format.', $t_args)); // Verify that each filter has a module name assigned. - $this->assertTrue(!empty($filter->module), t('Database: Proper module name for %filter in text format %format.', $t_args)); + $this->assertTrue(!empty($filter->module), format_string('Database: Proper module name for %filter in text format %format.', $t_args)); // Remove the filter from the copy of saved $format to check whether all // filters have been processed later. unset($format_filters[$name]); } // Verify that all filters have been processed. - $this->assertTrue(empty($format_filters), t('Database contains values for all filters in the saved format.')); + $this->assertTrue(empty($format_filters), 'Database contains values for all filters in the saved format.'); // Verify filter_list_format(). $filters = filter_list_format($format->format); @@ -143,20 +143,20 @@ class FilterCRUDTestCase extends DrupalWebTestCase { $t_args = array('%format' => $format->name, '%filter' => $name); // Verify that filter status is properly stored. - $this->assertEqual($filter->status, $format_filters[$name]['status'], t('filter_list_format: Proper status for %filter in text format %format.', $t_args)); + $this->assertEqual($filter->status, $format_filters[$name]['status'], format_string('filter_list_format: Proper status for %filter in text format %format.', $t_args)); // Verify that filter settings were properly stored. - $this->assertEqual($filter->settings, isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), t('filter_list_format: Proper filter settings for %filter in text format %format.', $t_args)); + $this->assertEqual($filter->settings, isset($format_filters[$name]['settings']) ? $format_filters[$name]['settings'] : array(), format_string('filter_list_format: Proper filter settings for %filter in text format %format.', $t_args)); // Verify that each filter has a module name assigned. - $this->assertTrue(!empty($filter->module), t('filter_list_format: Proper module name for %filter in text format %format.', $t_args)); + $this->assertTrue(!empty($filter->module), format_string('filter_list_format: Proper module name for %filter in text format %format.', $t_args)); // Remove the filter from the copy of saved $format to check whether all // filters have been processed later. unset($format_filters[$name]); } // Verify that all filters have been processed. - $this->assertTrue(empty($format_filters), t('filter_list_format: Loaded filters contain values for all filters in the saved format.')); + $this->assertTrue(empty($format_filters), 'filter_list_format: Loaded filters contain values for all filters in the saved format.'); } } @@ -205,14 +205,14 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Verify default weight of the text format. $this->drupalGet('admin/config/content/formats'); - $this->assertFieldByName("formats[$format_id][weight]", 0, t('Text format weight was saved.')); + $this->assertFieldByName("formats[$format_id][weight]", 0, 'Text format weight was saved.'); // Change the weight of the text format. $edit = array( "formats[$format_id][weight]" => 5, ); $this->drupalPost('admin/config/content/formats', $edit, t('Save changes')); - $this->assertFieldByName("formats[$format_id][weight]", 5, t('Text format weight was saved.')); + $this->assertFieldByName("formats[$format_id][weight]", 5, 'Text format weight was saved.'); // Edit text format. $this->drupalGet('admin/config/content/formats'); @@ -222,7 +222,7 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Verify that the custom weight of the text format has been retained. $this->drupalGet('admin/config/content/formats'); - $this->assertFieldByName("formats[$format_id][weight]", 5, t('Text format weight was retained.')); + $this->assertFieldByName("formats[$format_id][weight]", 5, 'Text format weight was retained.'); // Disable text format. $this->assertLinkByHref('admin/config/content/formats/' . $format_id . '/disable'); @@ -231,7 +231,7 @@ class FilterAdminTestCase extends DrupalWebTestCase { // Verify that disabled text format no longer exists. $this->drupalGet('admin/config/content/formats/' . $format_id); - $this->assertResponse(404, t('Disabled text format no longer exists.')); + $this->assertResponse(404, 'Disabled text format no longer exists.'); // Attempt to create a format of the same machine name as the disabled // format but with a different human readable name. @@ -268,44 +268,44 @@ class FilterAdminTestCase extends DrupalWebTestCase { $plain = 'plain_text'; // Check that the fallback format exists and cannot be disabled. - $this->assertTrue($plain == filter_fallback_format(), t('The fallback format is set to plain text.')); + $this->assertTrue($plain == filter_fallback_format(), 'The fallback format is set to plain text.'); $this->drupalGet('admin/config/content/formats'); - $this->assertNoRaw('admin/config/content/formats/' . $plain . '/disable', t('Disable link for the fallback format not found.')); + $this->assertNoRaw('admin/config/content/formats/' . $plain . '/disable', 'Disable link for the fallback format not found.'); $this->drupalGet('admin/config/content/formats/' . $plain . '/disable'); - $this->assertResponse(403, t('The fallback format cannot be disabled.')); + $this->assertResponse(403, 'The fallback format cannot be disabled.'); // Verify access permissions to Full HTML format. - $this->assertTrue(filter_access(filter_format_load($full), $this->admin_user), t('Admin user may use Full HTML.')); - $this->assertFalse(filter_access(filter_format_load($full), $this->web_user), t('Web user may not use Full HTML.')); + $this->assertTrue(filter_access(filter_format_load($full), $this->admin_user), 'Admin user may use Full HTML.'); + $this->assertFalse(filter_access(filter_format_load($full), $this->web_user), 'Web user may not use Full HTML.'); // Add an additional tag. $edit = array(); $edit['filters[filter_html][settings][allowed_html]'] = '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <quote>'; $this->drupalPost('admin/config/content/formats/' . $filtered, $edit, t('Save configuration')); - $this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], t('Allowed HTML tag added.')); + $this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], 'Allowed HTML tag added.'); $result = db_query('SELECT * FROM {cache_filter}')->fetchObject(); - $this->assertFalse($result, t('Cache cleared.')); + $this->assertFalse($result, 'Cache cleared.'); $elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', array( ':first' => 'filters[' . $first_filter . '][weight]', ':second' => 'filters[' . $second_filter . '][weight]', )); - $this->assertTrue(!empty($elements), t('Order confirmed in admin interface.')); + $this->assertTrue(!empty($elements), 'Order confirmed in admin interface.'); // Reorder filters. $edit = array(); $edit['filters[' . $second_filter . '][weight]'] = 1; $edit['filters[' . $first_filter . '][weight]'] = 2; $this->drupalPost(NULL, $edit, t('Save configuration')); - $this->assertFieldByName('filters[' . $second_filter . '][weight]', 1, t('Order saved successfully.')); - $this->assertFieldByName('filters[' . $first_filter . '][weight]', 2, t('Order saved successfully.')); + $this->assertFieldByName('filters[' . $second_filter . '][weight]', 1, 'Order saved successfully.'); + $this->assertFieldByName('filters[' . $first_filter . '][weight]', 2, 'Order saved successfully.'); $elements = $this->xpath('//select[@name=:first]/following::select[@name=:second]', array( ':first' => 'filters[' . $second_filter . '][weight]', ':second' => 'filters[' . $first_filter . '][weight]', )); - $this->assertTrue(!empty($elements), t('Reorder confirmed in admin interface.')); + $this->assertTrue(!empty($elements), 'Reorder confirmed in admin interface.'); $result = db_query('SELECT * FROM {filter} WHERE format = :format ORDER BY weight ASC', array(':format' => $filtered)); $filters = array(); @@ -314,7 +314,7 @@ class FilterAdminTestCase extends DrupalWebTestCase { $filters[] = $filter; } } - $this->assertTrue(($filters[0]->name == $second_filter && $filters[1]->name == $first_filter), t('Order confirmed in database.')); + $this->assertTrue(($filters[0]->name == $second_filter && $filters[1]->name == $first_filter), 'Order confirmed in database.'); // Add format. $edit = array(); @@ -324,19 +324,19 @@ class FilterAdminTestCase extends DrupalWebTestCase { $edit['filters[' . $second_filter . '][status]'] = TRUE; $edit['filters[' . $first_filter . '][status]'] = TRUE; $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration')); - $this->assertRaw(t('Added text format %format.', array('%format' => $edit['name'])), t('New filter created.')); + $this->assertRaw(t('Added text format %format.', array('%format' => $edit['name'])), 'New filter created.'); drupal_static_reset('filter_formats'); $format = filter_format_load($edit['format']); - $this->assertNotNull($format, t('Format found in database.')); + $this->assertNotNull($format, 'Format found in database.'); - $this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', '', t('Role found.')); - $this->assertFieldByName('filters[' . $second_filter . '][status]', '', t('Line break filter found.')); - $this->assertFieldByName('filters[' . $first_filter . '][status]', '', t('Url filter found.')); + $this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', '', 'Role found.'); + $this->assertFieldByName('filters[' . $second_filter . '][status]', '', 'Line break filter found.'); + $this->assertFieldByName('filters[' . $first_filter . '][status]', '', 'Url filter found.'); // Disable new filter. $this->drupalPost('admin/config/content/formats/' . $format->format . '/disable', array(), t('Disable')); - $this->assertRaw(t('Disabled text format %format.', array('%format' => $edit['name'])), t('Format successfully disabled.')); + $this->assertRaw(t('Disabled text format %format.', array('%format' => $edit['name'])), 'Format successfully disabled.'); // Allow authenticated users on full HTML. $format = filter_format_load($full); @@ -344,14 +344,14 @@ class FilterAdminTestCase extends DrupalWebTestCase { $edit['roles[' . DRUPAL_ANONYMOUS_RID . ']'] = 0; $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = 1; $this->drupalPost('admin/config/content/formats/' . $full, $edit, t('Save configuration')); - $this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->name)), t('Full HTML format successfully updated.')); + $this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->name)), 'Full HTML format successfully updated.'); // Switch user. $this->drupalLogout(); $this->drupalLogin($this->web_user); $this->drupalGet('node/add/page'); - $this->assertRaw('<option value="' . $full . '">Full HTML</option>', t('Full HTML filter accessible.')); + $this->assertRaw('<option value="' . $full . '">Full HTML</option>', 'Full HTML filter accessible.'); // Use filtered HTML and see if it removes tags that are not allowed. $body = '<em>' . $this->randomName() . '</em>'; @@ -364,20 +364,20 @@ class FilterAdminTestCase extends DrupalWebTestCase { $edit["body[$langcode][0][value]"] = $text; $edit["body[$langcode][0][format]"] = $filtered; $this->drupalPost('node/add/page', $edit, t('Save')); - $this->assertRaw(t('Basic page %title has been created.', array('%title' => $edit["title"])), t('Filtered node created.')); + $this->assertRaw(t('Basic page %title has been created.', array('%title' => $edit["title"])), 'Filtered node created.'); $node = $this->drupalGetNodeByTitle($edit["title"]); - $this->assertTrue($node, t('Node found in database.')); + $this->assertTrue($node, 'Node found in database.'); $this->drupalGet('node/' . $node->nid); - $this->assertRaw($body . $extra_text, t('Filter removed invalid tag.')); + $this->assertRaw($body . $extra_text, 'Filter removed invalid tag.'); // Use plain text and see if it escapes all tags, whether allowed or not. $edit = array(); $edit["body[$langcode][0][format]"] = $plain; $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->drupalGet('node/' . $node->nid); - $this->assertText(check_plain($text), t('The "Plain text" text format escapes all HTML tags.')); + $this->assertText(check_plain($text), 'The "Plain text" text format escapes all HTML tags.'); // Switch user. $this->drupalLogout(); @@ -388,22 +388,22 @@ class FilterAdminTestCase extends DrupalWebTestCase { $edit = array(); $edit['filters[filter_html][settings][allowed_html]'] = '<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>'; $this->drupalPost('admin/config/content/formats/' . $filtered, $edit, t('Save configuration')); - $this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], t('Changes reverted.')); + $this->assertFieldByName('filters[filter_html][settings][allowed_html]', $edit['filters[filter_html][settings][allowed_html]'], 'Changes reverted.'); // Full HTML. $edit = array(); $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = FALSE; $this->drupalPost('admin/config/content/formats/' . $full, $edit, t('Save configuration')); - $this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->name)), t('Full HTML format successfully reverted.')); - $this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'], t('Changes reverted.')); + $this->assertRaw(t('The text format %format has been updated.', array('%format' => $format->name)), 'Full HTML format successfully reverted.'); + $this->assertFieldByName('roles[' . DRUPAL_AUTHENTICATED_RID . ']', $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'], 'Changes reverted.'); // Filter order. $edit = array(); $edit['filters[' . $second_filter . '][weight]'] = 2; $edit['filters[' . $first_filter . '][weight]'] = 1; $this->drupalPost('admin/config/content/formats/' . $filtered, $edit, t('Save configuration')); - $this->assertFieldByName('filters[' . $second_filter . '][weight]', $edit['filters[' . $second_filter . '][weight]'], t('Changes reverted.')); - $this->assertFieldByName('filters[' . $first_filter . '][weight]', $edit['filters[' . $first_filter . '][weight]'], t('Changes reverted.')); + $this->assertFieldByName('filters[' . $second_filter . '][weight]', $edit['filters[' . $second_filter . '][weight]'], 'Changes reverted.'); + $this->assertFieldByName('filters[' . $first_filter . '][weight]', $edit['filters[' . $first_filter . '][weight]'], 'Changes reverted.'); } /** @@ -515,20 +515,20 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { function testFormatPermissions() { // Make sure that a regular user only has access to the text format they // were granted access to, as well to the fallback format. - $this->assertTrue(filter_access($this->allowed_format, $this->web_user), t('A regular user has access to a text format they were granted access to.')); - $this->assertFalse(filter_access($this->disallowed_format, $this->web_user), t('A regular user does not have access to a text format they were not granted access to.')); - $this->assertTrue(filter_access(filter_format_load(filter_fallback_format()), $this->web_user), t('A regular user has access to the fallback format.')); + $this->assertTrue(filter_access($this->allowed_format, $this->web_user), 'A regular user has access to a text format they were granted access to.'); + $this->assertFalse(filter_access($this->disallowed_format, $this->web_user), 'A regular user does not have access to a text format they were not granted access to.'); + $this->assertTrue(filter_access(filter_format_load(filter_fallback_format()), $this->web_user), 'A regular user has access to the fallback format.'); // Perform similar checks as above, but now against the entire list of // available formats for this user. - $this->assertTrue(in_array($this->allowed_format->format, array_keys(filter_formats($this->web_user))), t('The allowed format appears in the list of available formats for a regular user.')); - $this->assertFalse(in_array($this->disallowed_format->format, array_keys(filter_formats($this->web_user))), t('The disallowed format does not appear in the list of available formats for a regular user.')); - $this->assertTrue(in_array(filter_fallback_format(), array_keys(filter_formats($this->web_user))), t('The fallback format appears in the list of available formats for a regular user.')); + $this->assertTrue(in_array($this->allowed_format->format, array_keys(filter_formats($this->web_user))), 'The allowed format appears in the list of available formats for a regular user.'); + $this->assertFalse(in_array($this->disallowed_format->format, array_keys(filter_formats($this->web_user))), 'The disallowed format does not appear in the list of available formats for a regular user.'); + $this->assertTrue(in_array(filter_fallback_format(), array_keys(filter_formats($this->web_user))), 'The fallback format appears in the list of available formats for a regular user.'); // Make sure that a regular user only has permission to use the format // they were granted access to. - $this->assertTrue(user_access(filter_permission_name($this->allowed_format), $this->web_user), t('A regular user has permission to use the allowed text format.')); - $this->assertFalse(user_access(filter_permission_name($this->disallowed_format), $this->web_user), t('A regular user does not have permission to use the disallowed text format.')); + $this->assertTrue(user_access(filter_permission_name($this->allowed_format), $this->web_user), 'A regular user has permission to use the allowed text format.'); + $this->assertFalse(user_access(filter_permission_name($this->disallowed_format), $this->web_user), 'A regular user does not have permission to use the disallowed text format.'); // Make sure that the allowed format appears on the node form and that // the disallowed format does not. @@ -543,9 +543,9 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { foreach ($elements as $element) { $options[(string) $element['value']] = $element; } - $this->assertTrue(isset($options[$this->allowed_format->format]), t('The allowed text format appears as an option when adding a new node.')); - $this->assertFalse(isset($options[$this->disallowed_format->format]), t('The disallowed text format does not appear as an option when adding a new node.')); - $this->assertTrue(isset($options[filter_fallback_format()]), t('The fallback format appears as an option when adding a new node.')); + $this->assertTrue(isset($options[$this->allowed_format->format]), 'The allowed text format appears as an option when adding a new node.'); + $this->assertFalse(isset($options[$this->disallowed_format->format]), 'The disallowed text format does not appear as an option when adding a new node.'); + $this->assertTrue(isset($options[filter_fallback_format()]), 'The fallback format appears as an option when adding a new node.'); } /** @@ -558,17 +558,17 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { // Check that this role appears in the list of roles that have access to an // allowed text format, but does not appear in the list of roles that have // access to a disallowed text format. - $this->assertTrue(in_array($rid, array_keys(filter_get_roles_by_format($this->allowed_format))), t('A role which has access to a text format appears in the list of roles that have access to that format.')); - $this->assertFalse(in_array($rid, array_keys(filter_get_roles_by_format($this->disallowed_format))), t('A role which does not have access to a text format does not appear in the list of roles that have access to that format.')); + $this->assertTrue(in_array($rid, array_keys(filter_get_roles_by_format($this->allowed_format))), 'A role which has access to a text format appears in the list of roles that have access to that format.'); + $this->assertFalse(in_array($rid, array_keys(filter_get_roles_by_format($this->disallowed_format))), 'A role which does not have access to a text format does not appear in the list of roles that have access to that format.'); // Check that the correct text format appears in the list of formats // available to that role. - $this->assertTrue(in_array($this->allowed_format->format, array_keys(filter_get_formats_by_role($rid))), t('A text format which a role has access to appears in the list of formats available to that role.')); - $this->assertFalse(in_array($this->disallowed_format->format, array_keys(filter_get_formats_by_role($rid))), t('A text format which a role does not have access to does not appear in the list of formats available to that role.')); + $this->assertTrue(in_array($this->allowed_format->format, array_keys(filter_get_formats_by_role($rid))), 'A text format which a role has access to appears in the list of formats available to that role.'); + $this->assertFalse(in_array($this->disallowed_format->format, array_keys(filter_get_formats_by_role($rid))), 'A text format which a role does not have access to does not appear in the list of formats available to that role.'); // Check that the fallback format is always allowed. - $this->assertEqual(filter_get_roles_by_format(filter_format_load(filter_fallback_format())), user_roles(), t('All roles have access to the fallback format.')); - $this->assertTrue(in_array(filter_fallback_format(), array_keys(filter_get_formats_by_role($rid))), t('The fallback format appears in the list of allowed formats for any role.')); + $this->assertEqual(filter_get_roles_by_format(filter_format_load(filter_fallback_format())), user_roles(), 'All roles have access to the fallback format.'); + $this->assertTrue(in_array(filter_fallback_format(), array_keys(filter_get_formats_by_role($rid))), 'The fallback format appears in the list of allowed formats for any role.'); } /** @@ -601,19 +601,19 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { $this->clickLink(t('Edit')); // Verify that body field is read-only and contains replacement value. - $this->assertFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), t('Text format access denied message found.')); + $this->assertFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Text format access denied message found.'); // Verify that title can be changed, but preview displays original body. $new_edit = array(); $new_edit['title'] = $this->randomName(8); $this->drupalPost(NULL, $new_edit, t('Preview')); - $this->assertText($edit[$body_value_key], t('Old body found in preview.')); + $this->assertText($edit[$body_value_key], 'Old body found in preview.'); // Save and verify that only the title was changed. $this->drupalPost(NULL, $new_edit, t('Save')); - $this->assertNoText($edit['title'], t('Old title not found.')); - $this->assertText($new_edit['title'], t('New title found.')); - $this->assertText($edit[$body_value_key], t('Old body found.')); + $this->assertNoText($edit['title'], 'Old title not found.'); + $this->assertText($new_edit['title'], 'New title found.'); + $this->assertText($edit[$body_value_key], 'Old body found.'); // Check that even an administrator with "administer filters" permission // cannot edit the body field if they do not have specific permission to @@ -622,7 +622,7 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { // else.) $this->drupalLogin($this->filter_admin_user); $this->drupalGet('node/' . $node->nid . '/edit'); - $this->assertFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), t('Text format access denied message found.')); + $this->assertFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Text format access denied message found.'); // Disable the text format used above. filter_format_disable($this->disallowed_format); @@ -633,14 +633,14 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { // edit content that does not have an assigned format. $this->drupalLogin($this->web_user); $this->drupalGet('node/' . $node->nid . '/edit'); - $this->assertFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), t('Text format access denied message found.')); + $this->assertFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", t('This field has been disabled because you do not have sufficient permissions to edit it.'), 'Text format access denied message found.'); // Log back in as the filter administrator and verify that the body field // can be edited. $this->drupalLogin($this->filter_admin_user); $this->drupalGet('node/' . $node->nid . '/edit'); - $this->assertNoFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", NULL, t('Text format access denied message not found.')); - $this->assertFieldByXPath("//select[@name='$body_format_key']", NULL, t('Text format selector found.')); + $this->assertNoFieldByXPath("//textarea[@name='$body_value_key' and @disabled='disabled']", NULL, 'Text format access denied message not found.'); + $this->assertFieldByXPath("//select[@name='$body_format_key']", NULL, 'Text format selector found.'); // Verify that trying to save the node without selecting a new text format // produces an error message, and does not result in the node being saved. @@ -648,17 +648,17 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { $new_title = $this->randomName(8); $edit = array('title' => $new_title); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); - $this->assertText(t('!name field is required.', array('!name' => t('Text format'))), t('Error message is displayed.')); + $this->assertText(t('!name field is required.', array('!name' => t('Text format'))), 'Error message is displayed.'); $this->drupalGet('node/' . $node->nid); - $this->assertText($old_title, t('Old title found.')); - $this->assertNoText($new_title, t('New title not found.')); + $this->assertText($old_title, 'Old title found.'); + $this->assertNoText($new_title, 'New title not found.'); // Now select a new text format and make sure the node can be saved. $edit[$body_format_key] = filter_fallback_format(); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->assertUrl('node/' . $node->nid); - $this->assertText($new_title, t('New title found.')); - $this->assertNoText($old_title, t('Old title not found.')); + $this->assertText($new_title, 'New title found.'); + $this->assertNoText($old_title, 'Old title not found.'); // Switch the text format to a new one, then disable that format and all // other formats on the site (leaving only the fallback format). @@ -682,15 +682,15 @@ class FilterFormatAccessTestCase extends DrupalWebTestCase { $new_title = $this->randomName(8); $edit = array('title' => $new_title); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); - $this->assertText(t('!name field is required.', array('!name' => t('Text format'))), t('Error message is displayed.')); + $this->assertText(t('!name field is required.', array('!name' => t('Text format'))), 'Error message is displayed.'); $this->drupalGet('node/' . $node->nid); - $this->assertText($old_title, t('Old title found.')); - $this->assertNoText($new_title, t('New title not found.')); + $this->assertText($old_title, 'Old title found.'); + $this->assertNoText($new_title, 'New title not found.'); $edit[$body_format_key] = filter_fallback_format(); $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save')); $this->assertUrl('node/' . $node->nid); - $this->assertText($new_title, t('New title found.')); - $this->assertNoText($old_title, t('Old title not found.')); + $this->assertText($new_title, 'New title found.'); + $this->assertNoText($old_title, 'Old title not found.'); } /** @@ -747,8 +747,8 @@ class FilterDefaultFormatTestCase extends DrupalWebTestCase { // Check that each user's default format is the lowest weighted format that // the user has access to. - $this->assertEqual(filter_default_format($first_user), $first_format->format, t("The first user's default format is the lowest weighted format that the user has access to.")); - $this->assertEqual(filter_default_format($second_user), $second_format->format, t("The second user's default format is the lowest weighted format that the user has access to, and is different than the first user's.")); + $this->assertEqual(filter_default_format($first_user), $first_format->format, "The first user's default format is the lowest weighted format that the user has access to."); + $this->assertEqual(filter_default_format($second_user), $second_format->format, "The second user's default format is the lowest weighted format that the user has access to, and is different than the first user's."); // Reorder the two formats, and check that both users now have the same // default. @@ -756,7 +756,7 @@ class FilterDefaultFormatTestCase extends DrupalWebTestCase { $edit['formats[' . $second_format->format . '][weight]'] = $minimum_weight - 3; $this->drupalPost('admin/config/content/formats', $edit, t('Save changes')); $this->resetFilterCaches(); - $this->assertEqual(filter_default_format($first_user), filter_default_format($second_user), t('After the formats are reordered, both users have the same default format.')); + $this->assertEqual(filter_default_format($first_user), filter_default_format($second_user), 'After the formats are reordered, both users have the same default format.'); } /** @@ -793,7 +793,7 @@ class FilterNoFormatTestCase extends DrupalWebTestCase { // Make sure that when this text is run through check_markup() with no text // format, it is filtered as though it is in the fallback format. - $this->assertEqual(check_markup($text), check_markup($text, filter_fallback_format()), t('Text with no format is filtered the same as text in the fallback format.')); + $this->assertEqual(check_markup($text), check_markup($text, filter_fallback_format()), 'Text with no format is filtered the same as text in the fallback format.'); } } @@ -827,7 +827,7 @@ class FilterSecurityTestCase extends DrupalWebTestCase { $body_raw = $node->body[LANGUAGE_NONE][0]['value']; $format_id = $node->body[LANGUAGE_NONE][0]['format']; $this->drupalGet('node/' . $node->nid); - $this->assertText($body_raw, t('Node body found.')); + $this->assertText($body_raw, 'Node body found.'); // Enable the filter_test_replace filter. $edit = array( @@ -837,15 +837,15 @@ class FilterSecurityTestCase extends DrupalWebTestCase { // Verify that filter_test_replace filter replaced the content. $this->drupalGet('node/' . $node->nid); - $this->assertNoText($body_raw, t('Node body not found.')); - $this->assertText('Filter: Testing filter', t('Testing filter output found.')); + $this->assertNoText($body_raw, 'Node body not found.'); + $this->assertText('Filter: Testing filter', 'Testing filter output found.'); // Disable the text format entirely. $this->drupalPost('admin/config/content/formats/' . $format_id . '/disable', array(), t('Disable')); // Verify that the content is empty, because the text format does not exist. $this->drupalGet('node/' . $node->nid); - $this->assertNoText($body_raw, t('Node body not found.')); + $this->assertNoText($body_raw, 'Node body not found.'); } } @@ -932,7 +932,7 @@ class FilterUnitTestCase extends DrupalUnitTestCase { $limit = max(ini_get('pcre.backtrack_limit'), ini_get('pcre.recursion_limit')); $source = $this->randomName($limit); $result = _filter_autop($source); - $success = $this->assertEqual($result, '<p>' . $source . "</p>\n", t('Line break filter can process very long strings.')); + $success = $this->assertEqual($result, '<p>' . $source . "</p>\n", 'Line break filter can process very long strings.'); if (!$success) { $this->verbose("\n" . $source . "\n<hr />\n" . $result); } @@ -953,172 +953,172 @@ class FilterUnitTestCase extends DrupalUnitTestCase { function testFilterXSS() { // Tag stripping, different ways to work around removal of HTML tags. $f = filter_xss('<script>alert(0)</script>'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping -- simple script without special characters.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping -- simple script without special characters.'); $f = filter_xss('<script src="http://www.example.com" />'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping -- empty script with source.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping -- empty script with source.'); $f = filter_xss('<ScRipt sRc=http://www.example.com/>'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- varying case.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- varying case.'); $f = filter_xss("<script\nsrc\n=\nhttp://www.example.com/\n>"); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- multiline tag.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- multiline tag.'); $f = filter_xss('<script/a src=http://www.example.com/a.js></script>'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- non whitespace character after tag name.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- non whitespace character after tag name.'); $f = filter_xss('<script/src=http://www.example.com/a.js></script>'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- no space between tag and attribute.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- no space between tag and attribute.'); // Null between < and tag name works at least with IE6. $f = filter_xss("<\0scr\0ipt>alert(0)</script>"); - $this->assertNoNormalized($f, 'ipt', t('HTML tag stripping evasion -- breaking HTML with nulls.')); + $this->assertNoNormalized($f, 'ipt', 'HTML tag stripping evasion -- breaking HTML with nulls.'); $f = filter_xss("<scrscriptipt src=http://www.example.com/a.js>"); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- filter just removing "script".')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- filter just removing "script".'); $f = filter_xss('<<script>alert(0);//<</script>'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- double opening brackets.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- double opening brackets.'); $f = filter_xss('<script src=http://www.example.com/a.js?<b>'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- no closing tag.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- no closing tag.'); // DRUPAL-SA-2008-047: This doesn't seem exploitable, but the filter should // work consistently. $f = filter_xss('<script>>'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- double closing tag.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- double closing tag.'); $f = filter_xss('<script src=//www.example.com/.a>'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- no scheme or ending slash.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- no scheme or ending slash.'); $f = filter_xss('<script src=http://www.example.com/.a'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- no closing bracket.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- no closing bracket.'); $f = filter_xss('<script src=http://www.example.com/ <'); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- opening instead of closing bracket.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- opening instead of closing bracket.'); $f = filter_xss('<nosuchtag attribute="newScriptInjectionVector">'); - $this->assertNoNormalized($f, 'nosuchtag', t('HTML tag stripping evasion -- unknown tag.')); + $this->assertNoNormalized($f, 'nosuchtag', 'HTML tag stripping evasion -- unknown tag.'); $f = filter_xss('<?xml:namespace ns="urn:schemas-microsoft-com:time">'); - $this->assertTrue(stripos($f, '<?xml') === FALSE, t('HTML tag stripping evasion -- starting with a question sign (processing instructions).')); + $this->assertTrue(stripos($f, '<?xml') === FALSE, 'HTML tag stripping evasion -- starting with a question sign (processing instructions).'); $f = filter_xss('<t:set attributeName="innerHTML" to="<script defer>alert(0)</script>">'); - $this->assertNoNormalized($f, 't:set', t('HTML tag stripping evasion -- colon in the tag name (namespaces\' tricks).')); + $this->assertNoNormalized($f, 't:set', 'HTML tag stripping evasion -- colon in the tag name (namespaces\' tricks).'); $f = filter_xss('<img """><script>alert(0)</script>', array('img')); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- a malformed image tag.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- a malformed image tag.'); $f = filter_xss('<blockquote><script>alert(0)</script></blockquote>', array('blockquote')); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- script in a blockqoute.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- script in a blockqoute.'); $f = filter_xss("<!--[if true]><script>alert(0)</script><![endif]-->"); - $this->assertNoNormalized($f, 'script', t('HTML tag stripping evasion -- script within a comment.')); + $this->assertNoNormalized($f, 'script', 'HTML tag stripping evasion -- script within a comment.'); // Dangerous attributes removal. $f = filter_xss('<p onmouseover="http://www.example.com/">', array('p')); - $this->assertNoNormalized($f, 'onmouseover', t('HTML filter attributes removal -- events, no evasion.')); + $this->assertNoNormalized($f, 'onmouseover', 'HTML filter attributes removal -- events, no evasion.'); $f = filter_xss('<li style="list-style-image: url(javascript:alert(0))">', array('li')); - $this->assertNoNormalized($f, 'style', t('HTML filter attributes removal -- style, no evasion.')); + $this->assertNoNormalized($f, 'style', 'HTML filter attributes removal -- style, no evasion.'); $f = filter_xss('<img onerror =alert(0)>', array('img')); - $this->assertNoNormalized($f, 'onerror', t('HTML filter attributes removal evasion -- spaces before equals sign.')); + $this->assertNoNormalized($f, 'onerror', 'HTML filter attributes removal evasion -- spaces before equals sign.'); $f = filter_xss('<img onabort!#$%&()*~+-_.,:;?@[/|\]^`=alert(0)>', array('img')); - $this->assertNoNormalized($f, 'onabort', t('HTML filter attributes removal evasion -- non alphanumeric characters before equals sign.')); + $this->assertNoNormalized($f, 'onabort', 'HTML filter attributes removal evasion -- non alphanumeric characters before equals sign.'); $f = filter_xss('<img oNmediAError=alert(0)>', array('img')); - $this->assertNoNormalized($f, 'onmediaerror', t('HTML filter attributes removal evasion -- varying case.')); + $this->assertNoNormalized($f, 'onmediaerror', 'HTML filter attributes removal evasion -- varying case.'); // Works at least with IE6. $f = filter_xss("<img o\0nfocus\0=alert(0)>", array('img')); - $this->assertNoNormalized($f, 'focus', t('HTML filter attributes removal evasion -- breaking with nulls.')); + $this->assertNoNormalized($f, 'focus', 'HTML filter attributes removal evasion -- breaking with nulls.'); // Only whitelisted scheme names allowed in attributes. $f = filter_xss('<img src="javascript:alert(0)">', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing -- no evasion.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing -- no evasion.'); $f = filter_xss('<img src=javascript:alert(0)>', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- no quotes.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- no quotes.'); // A bit like CVE-2006-0070. $f = filter_xss('<img src="javascript:confirm(0)">', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- no alert ;)')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- no alert ;)'); $f = filter_xss('<img src=`javascript:alert(0)`>', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- grave accents.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- grave accents.'); $f = filter_xss('<img dynsrc="javascript:alert(0)">', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing -- rare attribute.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing -- rare attribute.'); $f = filter_xss('<table background="javascript:alert(0)">', array('table')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing -- another tag.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing -- another tag.'); $f = filter_xss('<base href="javascript:alert(0);//">', array('base')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing -- one more attribute and tag.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing -- one more attribute and tag.'); $f = filter_xss('<img src="jaVaSCriPt:alert(0)">', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- varying case.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- varying case.'); $f = filter_xss('<img src=javascript:alert(0)>', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- UTF-8 decimal encoding.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- UTF-8 decimal encoding.'); $f = filter_xss('<img src=javascript:alert(0)>', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- long UTF-8 encoding.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- long UTF-8 encoding.'); $f = filter_xss('<img src=javascript:alert(0)>', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- UTF-8 hex encoding.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- UTF-8 hex encoding.'); $f = filter_xss("<img src=\"jav\tascript:alert(0)\">", array('img')); - $this->assertNoNormalized($f, 'script', t('HTML scheme clearing evasion -- an embedded tab.')); + $this->assertNoNormalized($f, 'script', 'HTML scheme clearing evasion -- an embedded tab.'); $f = filter_xss('<img src="jav	ascript:alert(0)">', array('img')); - $this->assertNoNormalized($f, 'script', t('HTML scheme clearing evasion -- an encoded, embedded tab.')); + $this->assertNoNormalized($f, 'script', 'HTML scheme clearing evasion -- an encoded, embedded tab.'); $f = filter_xss('<img src="jav
ascript:alert(0)">', array('img')); - $this->assertNoNormalized($f, 'script', t('HTML scheme clearing evasion -- an encoded, embedded newline.')); + $this->assertNoNormalized($f, 'script', 'HTML scheme clearing evasion -- an encoded, embedded newline.'); // With 
 this test would fail, but the entity gets turned into // &#xD;, so it's OK. $f = filter_xss('<img src="jav
ascript:alert(0)">', array('img')); - $this->assertNoNormalized($f, 'script', t('HTML scheme clearing evasion -- an encoded, embedded carriage return.')); + $this->assertNoNormalized($f, 'script', 'HTML scheme clearing evasion -- an encoded, embedded carriage return.'); $f = filter_xss("<img src=\"\n\n\nj\na\nva\ns\ncript:alert(0)\">", array('img')); - $this->assertNoNormalized($f, 'cript', t('HTML scheme clearing evasion -- broken into many lines.')); + $this->assertNoNormalized($f, 'cript', 'HTML scheme clearing evasion -- broken into many lines.'); $f = filter_xss("<img src=\"jav\0a\0\0cript:alert(0)\">", array('img')); - $this->assertNoNormalized($f, 'cript', t('HTML scheme clearing evasion -- embedded nulls.')); + $this->assertNoNormalized($f, 'cript', 'HTML scheme clearing evasion -- embedded nulls.'); $f = filter_xss('<img src="  javascript:alert(0)">', array('img')); - $this->assertNoNormalized($f, 'javascript', t('HTML scheme clearing evasion -- spaces and metacharacters before scheme.')); + $this->assertNoNormalized($f, 'javascript', 'HTML scheme clearing evasion -- spaces and metacharacters before scheme.'); $f = filter_xss('<img src="vbscript:msgbox(0)">', array('img')); - $this->assertNoNormalized($f, 'vbscript', t('HTML scheme clearing evasion -- another scheme.')); + $this->assertNoNormalized($f, 'vbscript', 'HTML scheme clearing evasion -- another scheme.'); $f = filter_xss('<img src="nosuchscheme:notice(0)">', array('img')); - $this->assertNoNormalized($f, 'nosuchscheme', t('HTML scheme clearing evasion -- unknown scheme.')); + $this->assertNoNormalized($f, 'nosuchscheme', 'HTML scheme clearing evasion -- unknown scheme.'); // Netscape 4.x javascript entities. $f = filter_xss('<br size="&{alert(0)}">', array('br')); - $this->assertNoNormalized($f, 'alert', t('Netscape 4.x javascript entities.')); + $this->assertNoNormalized($f, 'alert', 'Netscape 4.x javascript entities.'); // DRUPAL-SA-2008-006: Invalid UTF-8, these only work as reflected XSS with // Internet Explorer 6. $f = filter_xss("<p arg=\"\xe0\">\" style=\"background-image: url(javascript:alert(0));\"\xe0<p>", array('p')); - $this->assertNoNormalized($f, 'style', t('HTML filter -- invalid UTF-8.')); + $this->assertNoNormalized($f, 'style', 'HTML filter -- invalid UTF-8.'); $f = filter_xss("\xc0aaa"); - $this->assertEqual($f, '', t('HTML filter -- overlong UTF-8 sequences.')); + $this->assertEqual($f, '', 'HTML filter -- overlong UTF-8 sequences.'); $f = filter_xss("Who's Online"); - $this->assertNormalized($f, "who's online", t('HTML filter -- html entity number')); + $this->assertNormalized($f, "who's online", 'HTML filter -- html entity number'); $f = filter_xss("Who&#039;s Online"); - $this->assertNormalized($f, "who's online", t('HTML filter -- encoded html entity number')); + $this->assertNormalized($f, "who's online", 'HTML filter -- encoded html entity number'); $f = filter_xss("Who&amp;#039; Online"); - $this->assertNormalized($f, "who&#039; online", t('HTML filter -- double encoded html entity number')); + $this->assertNormalized($f, "who&#039; online", 'HTML filter -- double encoded html entity number'); } /** @@ -1147,34 +1147,34 @@ class FilterUnitTestCase extends DrupalUnitTestCase { // HTML filter is not able to secure some tags, these should never be // allowed. $f = _filter_html('<script />', $filter); - $this->assertNoNormalized($f, 'script', t('HTML filter should always remove script tags.')); + $this->assertNoNormalized($f, 'script', 'HTML filter should always remove script tags.'); $f = _filter_html('<iframe />', $filter); - $this->assertNoNormalized($f, 'iframe', t('HTML filter should always remove iframe tags.')); + $this->assertNoNormalized($f, 'iframe', 'HTML filter should always remove iframe tags.'); $f = _filter_html('<object />', $filter); - $this->assertNoNormalized($f, 'object', t('HTML filter should always remove object tags.')); + $this->assertNoNormalized($f, 'object', 'HTML filter should always remove object tags.'); $f = _filter_html('<style />', $filter); - $this->assertNoNormalized($f, 'style', t('HTML filter should always remove style tags.')); + $this->assertNoNormalized($f, 'style', 'HTML filter should always remove style tags.'); // Some tags make CSRF attacks easier, let the user take the risk herself. $f = _filter_html('<img />', $filter); - $this->assertNoNormalized($f, 'img', t('HTML filter should remove img tags on default.')); + $this->assertNoNormalized($f, 'img', 'HTML filter should remove img tags on default.'); $f = _filter_html('<input />', $filter); - $this->assertNoNormalized($f, 'img', t('HTML filter should remove input tags on default.')); + $this->assertNoNormalized($f, 'img', 'HTML filter should remove input tags on default.'); // Filtering content of some attributes is infeasible, these shouldn't be // allowed too. $f = _filter_html('<p style="display: none;" />', $filter); - $this->assertNoNormalized($f, 'style', t('HTML filter should remove style attribute on default.')); + $this->assertNoNormalized($f, 'style', 'HTML filter should remove style attribute on default.'); $f = _filter_html('<p onerror="alert(0);" />', $filter); - $this->assertNoNormalized($f, 'onerror', t('HTML filter should remove on* attributes on default.')); + $this->assertNoNormalized($f, 'onerror', 'HTML filter should remove on* attributes on default.'); $f = _filter_html('<code onerror> </code>', $filter); - $this->assertNoNormalized($f, 'onerror', t('HTML filter should remove empty on* attributes on default.')); + $this->assertNoNormalized($f, 'onerror', 'HTML filter should remove empty on* attributes on default.'); } /** @@ -1192,20 +1192,20 @@ class FilterUnitTestCase extends DrupalUnitTestCase { // Test if the rel="nofollow" attribute is added, even if we try to prevent // it. $f = _filter_html('<a href="http://www.example.com/">text</a>', $filter); - $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent -- no evasion.')); + $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent -- no evasion.'); $f = _filter_html('<A href="http://www.example.com/">text</a>', $filter); - $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- capital A.')); + $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- capital A.'); $f = _filter_html("<a/href=\"http://www.example.com/\">text</a>", $filter); - $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- non whitespace character after tag name.')); + $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- non whitespace character after tag name.'); $f = _filter_html("<\0a\0 href=\"http://www.example.com/\">text</a>", $filter); - $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- some nulls.')); + $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- some nulls.'); $f = _filter_html('<a href="http://www.example.com/" rel="follow">text</a>', $filter); - $this->assertNoNormalized($f, 'rel="follow"', t('Spam deterrent evasion -- with rel set - rel="follow" removed.')); - $this->assertNormalized($f, 'rel="nofollow"', t('Spam deterrent evasion -- with rel set - rel="nofollow" added.')); + $this->assertNoNormalized($f, 'rel="follow"', 'Spam deterrent evasion -- with rel set - rel="follow" removed.'); + $this->assertNormalized($f, 'rel="nofollow"', 'Spam deterrent evasion -- with rel set - rel="nofollow" added.'); } /** @@ -1214,13 +1214,13 @@ class FilterUnitTestCase extends DrupalUnitTestCase { function testFilterXSSAdmin() { // DRUPAL-SA-2008-044 $f = filter_xss_admin('<object />'); - $this->assertNoNormalized($f, 'object', t('Admin HTML filter -- should not allow object tag.')); + $this->assertNoNormalized($f, 'object', 'Admin HTML filter -- should not allow object tag.'); $f = filter_xss_admin('<script />'); - $this->assertNoNormalized($f, 'script', t('Admin HTML filter -- should not allow script tag.')); + $this->assertNoNormalized($f, 'script', 'Admin HTML filter -- should not allow script tag.'); $f = filter_xss_admin('<style /><iframe /><frame /><frameset /><meta /><link /><embed /><applet /><param /><layer />'); - $this->assertEqual($f, '', t('Admin HTML filter -- should never allow some tags.')); + $this->assertEqual($f, '', 'Admin HTML filter -- should never allow some tags.'); } /** @@ -1549,13 +1549,13 @@ www.example.com with a newline in comments --> foreach ($tasks as $value => $is_expected) { // Not using assertIdentical, since combination with strpos() is hard to grok. if ($is_expected) { - $success = $this->assertTrue(strpos($result, $value) !== FALSE, t('@source: @value found.', array( + $success = $this->assertTrue(strpos($result, $value) !== FALSE, format_string('@source: @value found.', array( '@source' => var_export($source, TRUE), '@value' => var_export($value, TRUE), ))); } else { - $success = $this->assertTrue(strpos($result, $value) === FALSE, t('@source: @value not found.', array( + $success = $this->assertTrue(strpos($result, $value) === FALSE, format_string('@source: @value not found.', array( '@source' => var_export($source, TRUE), '@value' => var_export($value, TRUE), ))); @@ -1610,114 +1610,114 @@ www.example.com with a newline in comments --> function testHtmlCorrectorFilter() { // Tag closing. $f = _filter_htmlcorrector('<p>text'); - $this->assertEqual($f, '<p>text</p>', t('HTML corrector -- tag closing at the end of input.')); + $this->assertEqual($f, '<p>text</p>', 'HTML corrector -- tag closing at the end of input.'); $f = _filter_htmlcorrector('<p>text<p><p>text'); - $this->assertEqual($f, '<p>text</p><p></p><p>text</p>', t('HTML corrector -- tag closing.')); + $this->assertEqual($f, '<p>text</p><p></p><p>text</p>', 'HTML corrector -- tag closing.'); $f = _filter_htmlcorrector("<ul><li>e1<li>e2"); - $this->assertEqual($f, "<ul><li>e1</li><li>e2</li></ul>", t('HTML corrector -- unclosed list tags.')); + $this->assertEqual($f, "<ul><li>e1</li><li>e2</li></ul>", 'HTML corrector -- unclosed list tags.'); $f = _filter_htmlcorrector('<div id="d">content'); - $this->assertEqual($f, '<div id="d">content</div>', t('HTML corrector -- unclosed tag with attribute.')); + $this->assertEqual($f, '<div id="d">content</div>', 'HTML corrector -- unclosed tag with attribute.'); // XHTML slash for empty elements. $f = _filter_htmlcorrector('<hr><br>'); - $this->assertEqual($f, '<hr /><br />', t('HTML corrector -- XHTML closing slash.')); + $this->assertEqual($f, '<hr /><br />', 'HTML corrector -- XHTML closing slash.'); $f = _filter_htmlcorrector('<P>test</P>'); - $this->assertEqual($f, '<p>test</p>', t('HTML corrector -- Convert uppercased tags to proper lowercased ones.')); + $this->assertEqual($f, '<p>test</p>', 'HTML corrector -- Convert uppercased tags to proper lowercased ones.'); $f = _filter_htmlcorrector('<P>test</p>'); - $this->assertEqual($f, '<p>test</p>', t('HTML corrector -- Convert uppercased tags to proper lowercased ones.')); + $this->assertEqual($f, '<p>test</p>', 'HTML corrector -- Convert uppercased tags to proper lowercased ones.'); $f = _filter_htmlcorrector('test<hr />'); - $this->assertEqual($f, 'test<hr />', t('HTML corrector -- Let proper XHTML pass through.')); + $this->assertEqual($f, 'test<hr />', 'HTML corrector -- Let proper XHTML pass through.'); $f = _filter_htmlcorrector('test<hr/>'); - $this->assertEqual($f, 'test<hr />', t('HTML corrector -- Let proper XHTML pass through, but ensure there is a single space before the closing slash.')); + $this->assertEqual($f, 'test<hr />', 'HTML corrector -- Let proper XHTML pass through, but ensure there is a single space before the closing slash.'); $f = _filter_htmlcorrector('test<hr />'); - $this->assertEqual($f, 'test<hr />', t('HTML corrector -- Let proper XHTML pass through, but ensure there are not too many spaces before the closing slash.')); + $this->assertEqual($f, 'test<hr />', 'HTML corrector -- Let proper XHTML pass through, but ensure there are not too many spaces before the closing slash.'); $f = _filter_htmlcorrector('<span class="test" />'); - $this->assertEqual($f, '<span class="test"></span>', t('HTML corrector -- Convert XHTML that is properly formed but that would not be compatible with typical HTML user agents.')); + $this->assertEqual($f, '<span class="test"></span>', 'HTML corrector -- Convert XHTML that is properly formed but that would not be compatible with typical HTML user agents.'); $f = _filter_htmlcorrector('test1<br class="test">test2'); - $this->assertEqual($f, 'test1<br class="test" />test2', t('HTML corrector -- Automatically close single tags.')); + $this->assertEqual($f, 'test1<br class="test" />test2', 'HTML corrector -- Automatically close single tags.'); $f = _filter_htmlcorrector('line1<hr>line2'); - $this->assertEqual($f, 'line1<hr />line2', t('HTML corrector -- Automatically close single tags.')); + $this->assertEqual($f, 'line1<hr />line2', 'HTML corrector -- Automatically close single tags.'); $f = _filter_htmlcorrector('line1<HR>line2'); - $this->assertEqual($f, 'line1<hr />line2', t('HTML corrector -- Automatically close single tags.')); + $this->assertEqual($f, 'line1<hr />line2', 'HTML corrector -- Automatically close single tags.'); $f = _filter_htmlcorrector('<img src="http://example.com/test.jpg">test</img>'); - $this->assertEqual($f, '<img src="http://example.com/test.jpg" />test', t('HTML corrector -- Automatically close single tags.')); + $this->assertEqual($f, '<img src="http://example.com/test.jpg" />test', 'HTML corrector -- Automatically close single tags.'); $f = _filter_htmlcorrector('<br></br>'); - $this->assertEqual($f, '<br />', t("HTML corrector -- Transform empty tags to a single closed tag if the tag's content model is EMPTY.")); + $this->assertEqual($f, '<br />', "HTML corrector -- Transform empty tags to a single closed tag if the tag's content model is EMPTY."); $f = _filter_htmlcorrector('<div></div>'); - $this->assertEqual($f, '<div></div>', t("HTML corrector -- Do not transform empty tags to a single closed tag if the tag's content model is not EMPTY.")); + $this->assertEqual($f, '<div></div>', "HTML corrector -- Do not transform empty tags to a single closed tag if the tag's content model is not EMPTY."); $f = _filter_htmlcorrector('<p>line1<br/><hr/>line2</p>'); - $this->assertEqual($f, '<p>line1<br /></p><hr />line2', t('HTML corrector -- Move non-inline elements outside of inline containers.')); + $this->assertEqual($f, '<p>line1<br /></p><hr />line2', 'HTML corrector -- Move non-inline elements outside of inline containers.'); $f = _filter_htmlcorrector('<p>line1<div>line2</div></p>'); - $this->assertEqual($f, '<p>line1</p><div>line2</div>', t('HTML corrector -- Move non-inline elements outside of inline containers.')); + $this->assertEqual($f, '<p>line1</p><div>line2</div>', 'HTML corrector -- Move non-inline elements outside of inline containers.'); $f = _filter_htmlcorrector('<p>test<p>test</p>\n'); - $this->assertEqual($f, '<p>test</p><p>test</p>\n', t('HTML corrector -- Auto-close improperly nested tags.')); + $this->assertEqual($f, '<p>test</p><p>test</p>\n', 'HTML corrector -- Auto-close improperly nested tags.'); $f = _filter_htmlcorrector('<p>Line1<br><STRONG>bold stuff</b>'); - $this->assertEqual($f, '<p>Line1<br /><strong>bold stuff</strong></p>', t('HTML corrector -- Properly close unclosed tags, and remove useless closing tags.')); + $this->assertEqual($f, '<p>Line1<br /><strong>bold stuff</strong></p>', 'HTML corrector -- Properly close unclosed tags, and remove useless closing tags.'); $f = _filter_htmlcorrector('test <!-- this is a comment -->'); - $this->assertEqual($f, 'test <!-- this is a comment -->', t('HTML corrector -- Do not touch HTML comments.')); + $this->assertEqual($f, 'test <!-- this is a comment -->', 'HTML corrector -- Do not touch HTML comments.'); $f = _filter_htmlcorrector('test <!--this is a comment-->'); - $this->assertEqual($f, 'test <!--this is a comment-->', t('HTML corrector -- Do not touch HTML comments.')); + $this->assertEqual($f, 'test <!--this is a comment-->', 'HTML corrector -- Do not touch HTML comments.'); $f = _filter_htmlcorrector('test <!-- comment <p>another <strong>multiple</strong> line comment</p> -->'); $this->assertEqual($f, 'test <!-- comment <p>another <strong>multiple</strong> line - comment</p> -->', t('HTML corrector -- Do not touch HTML comments.')); + comment</p> -->', 'HTML corrector -- Do not touch HTML comments.'); $f = _filter_htmlcorrector('test <!-- comment <p>another comment</p> -->'); - $this->assertEqual($f, 'test <!-- comment <p>another comment</p> -->', t('HTML corrector -- Do not touch HTML comments.')); + $this->assertEqual($f, 'test <!-- comment <p>another comment</p> -->', 'HTML corrector -- Do not touch HTML comments.'); $f = _filter_htmlcorrector('test <!--break-->'); - $this->assertEqual($f, 'test <!--break-->', t('HTML corrector -- Do not touch HTML comments.')); + $this->assertEqual($f, 'test <!--break-->', 'HTML corrector -- Do not touch HTML comments.'); $f = _filter_htmlcorrector('<p>test\n</p>\n'); - $this->assertEqual($f, '<p>test\n</p>\n', t('HTML corrector -- New-lines are accepted and kept as-is.')); + $this->assertEqual($f, '<p>test\n</p>\n', 'HTML corrector -- New-lines are accepted and kept as-is.'); $f = _filter_htmlcorrector('<p>دروبال'); - $this->assertEqual($f, '<p>دروبال</p>', t('HTML corrector -- Encoding is correctly kept.')); + $this->assertEqual($f, '<p>دروبال</p>', 'HTML corrector -- Encoding is correctly kept.'); $f = _filter_htmlcorrector('<script type="text/javascript">alert("test")</script>'); $this->assertEqual($f, '<script type="text/javascript"> <!--//--><![CDATA[// ><!-- alert("test") //--><!]]> -</script>', t('HTML corrector -- CDATA added to script element')); +</script>', 'HTML corrector -- CDATA added to script element'); $f = _filter_htmlcorrector('<p><script type="text/javascript">alert("test")</script></p>'); $this->assertEqual($f, '<p><script type="text/javascript"> <!--//--><![CDATA[// ><!-- alert("test") //--><!]]> -</script></p>', t('HTML corrector -- CDATA added to a nested script element')); +</script></p>', 'HTML corrector -- CDATA added to a nested script element'); $f = _filter_htmlcorrector('<p><style> /* Styling */ body {color:red}</style></p>'); $this->assertEqual($f, '<p><style> <!--/*--><![CDATA[/* ><!--*/ /* Styling */ body {color:red} /*--><!]]>*/ -</style></p>', t('HTML corrector -- CDATA added to a style element.')); +</style></p>', 'HTML corrector -- CDATA added to a style element.'); $filtered_data = _filter_htmlcorrector('<p><style> /*<![CDATA[*/ @@ -1735,7 +1735,7 @@ body {color:red} /*--><!]]>*/ </style></p>', - t('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '/*<![CDATA[*/')) + format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '/*<![CDATA[*/')) ); $filtered_data = _filter_htmlcorrector('<p><style> @@ -1754,7 +1754,7 @@ body {color:red} /*--><!]]>*/ </style></p>', - t('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--/*--><![CDATA[/* ><!--*/')) + format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--/*--><![CDATA[/* ><!--*/')) ); $filtered_data = _filter_htmlcorrector('<p><script type="text/javascript"> @@ -1771,7 +1771,7 @@ body {color:red} //--><!]]> </script></p>', - t('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--//--><![CDATA[// ><!--')) + format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '<!--//--><![CDATA[// ><!--')) ); $filtered_data = _filter_htmlcorrector('<p><script type="text/javascript"> @@ -1788,7 +1788,7 @@ body {color:red} //--><!]]> </script></p>', - t('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '// <![CDATA[')) + format_string('HTML corrector -- Existing cdata section @pattern_name properly escaped', array('@pattern_name' => '// <![CDATA[')) ); } @@ -1874,8 +1874,8 @@ class FilterHooksTestCase extends DrupalWebTestCase { $edit['name'] = $name; $edit['roles[' . DRUPAL_ANONYMOUS_RID . ']'] = 1; $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration')); - $this->assertRaw(t('Added text format %format.', array('%format' => $name)), t('New format created.')); - $this->assertText('hook_filter_format_insert invoked.', t('hook_filter_format_insert was invoked.')); + $this->assertRaw(t('Added text format %format.', array('%format' => $name)), 'New format created.'); + $this->assertText('hook_filter_format_insert invoked.', 'hook_filter_format_insert was invoked.'); $format_id = $edit['format']; @@ -1883,8 +1883,8 @@ class FilterHooksTestCase extends DrupalWebTestCase { $edit = array(); $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = 1; $this->drupalPost('admin/config/content/formats/' . $format_id, $edit, t('Save configuration')); - $this->assertRaw(t('The text format %format has been updated.', array('%format' => $name)), t('Format successfully updated.')); - $this->assertText('hook_filter_format_update invoked.', t('hook_filter_format_update() was invoked.')); + $this->assertRaw(t('The text format %format has been updated.', array('%format' => $name)), 'Format successfully updated.'); + $this->assertText('hook_filter_format_update invoked.', 'hook_filter_format_update() was invoked.'); // Add a new custom block. $custom_block = array(); @@ -1894,16 +1894,16 @@ class FilterHooksTestCase extends DrupalWebTestCase { // Use the format created. $custom_block['body[format]'] = $format_id; $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block')); - $this->assertText(t('The block has been created.'), t('New block successfully created.')); + $this->assertText(t('The block has been created.'), 'New block successfully created.'); // Verify the new block is in the database. $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField(); - $this->assertNotNull($bid, t('New block found in database')); + $this->assertNotNull($bid, 'New block found in database'); // Disable the text format. $this->drupalPost('admin/config/content/formats/' . $format_id . '/disable', array(), t('Disable')); - $this->assertRaw(t('Disabled text format %format.', array('%format' => $name)), t('Format successfully disabled.')); - $this->assertText('hook_filter_format_disable invoked.', t('hook_filter_format_disable() was invoked.')); + $this->assertRaw(t('Disabled text format %format.', array('%format' => $name)), 'Format successfully disabled.'); + $this->assertText('hook_filter_format_disable invoked.', 'hook_filter_format_disable() was invoked.'); } } |