Download & Extend

Clean up filter-related tests that load text formats by their human-readable name

Project:Drupal core
Version:7.x-dev
Component:filter.module
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:Novice

Issue Summary

There are a lot of tests in the filter.module and elsewhere throughout Drupal core that have code like this:

<?php
    $filtered_html_format
= db_query_range('SELECT * FROM {filter_format} WHERE name = :name', 0, 1, array(':name' => 'Filtered HTML'))->fetchObject();
?>

That ugly code is no longer necessary anymore due to #934050: Change format into string - instead, we can just use the known, machine-readable name of the format directly, i.e. we could call filter_format_load('filtered_html') in the example above.

Comments

#1

I'm tagging this "Novice", although maybe it's not for extreme novices. But it's a good patch for someone who wants to learn their way around a bunch of core tests.

#2

Status:active» needs review

While somewhat novice, I'd like to ensure some sanity here.

AttachmentSizeStatusTest resultOperations
drupal.filter-format-tests.2.patch14.1 KBIdleFAILED: [[SimpleTest]]: [MySQL] 26,962 pass(es), 15 fail(s), and 9 exception(es).View details

#3

Status:needs review» needs work

The last submitted patch, drupal.filter-format-tests.2.patch, failed testing.

#4

Status:needs work» needs review

Stupid copy and paste mistake, sorry. Looks RTBC to me.

AttachmentSizeStatusTest resultOperations
drupal.filter-format-tests.4.patch14.11 KBIdleFAILED: [[SimpleTest]]: [MySQL] 27,689 pass(es), 16 fail(s), and 9 exception(es).View details

#5

Status:needs review» needs work

The last submitted patch, drupal.filter-format-tests.4.patch, failed testing.

#6

Status:needs work» needs review

Fixed those test failures:

In FilterAdminTestCase, a new text format is created (or edited) in the internal browser. Afterwards, the test code in the parent site tries to load that format in order to build administration URLs. However, filter_format_load() resp. filter_formats() is statically cached, so the new format does not exist in the parent site.

AttachmentSizeStatusTest resultOperations
drupal.filter-format-tests.6.patch15.11 KBIdlePASSED: [[SimpleTest]]: [MySQL] 28,791 pass(es).View details

#7

Removed needless usage of filter_format_load() where possible.

AttachmentSizeStatusTest resultOperations
drupal.filter-format-tests.7.patch16.43 KBIdlePASSED: [[SimpleTest]]: [MySQL] 28,808 pass(es).View details

#8

Status:needs review» reviewed & tested by the community

Looks perfectly reasonable to me.

I also checked for places this patch might have missed, and couldn't find any. This seems to catch/fix all cases where the text formats were loaded by human-readable name.

#9

Status:reviewed & tested by the community» fixed

This looks like a good clean-up to me, as long as contrib tests aren't affected by the loss of those two functions. If we receive any reports of breakage, we're going to need to add those back in as dumb wrappers with a "@todo remove in D8" around them.

Committed to HEAD.

#10

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here