1 filter.test | FilterCRUDTestCase::verifyTextFormat($format) |
Verifies that a text format is properly stored.
File
- core/
modules/ filter/ tests/ filter.test, line 82 - Tests for filter.module.
Class
- FilterCRUDTestCase
- Tests for text format and filter CRUD operations.
Code
function verifyTextFormat($format) {
$t_args = array('%format' => $format->name);
// Verify text format database record.
$config_format = (object) config_get('filter.format.' . $format->format);
$this->assertEqual($config_format->format, $format->format, format_string('Database: Proper format id for text format %format.', $t_args));
$this->assertEqual($config_format->name, $format->name, format_string('Database: Proper title for text format %format.', $t_args));
$this->assertEqual($config_format->cache, $format->cache, format_string('Database: Proper cache indicator for text format %format.', $t_args));
$this->assertEqual($config_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, 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();
$cacheable = TRUE;
foreach ($filter_format->filters as $name => $filter) {
// If this filter is not cacheable, update $cacheable accordingly, so we
// can verify $format->cache after iterating over all filters.
if ($filter->status && isset($filter_info[$name]['cache']) && !$filter_info[$name]['cache']) {
$cacheable = FALSE;
break;
}
}
$this->assertEqual($filter_format->cache, $cacheable, 'Text format contains proper cache property.');
}