protected function CustomFormattersTestCase::createCustomFormatter in Custom Formatters 7.2
Create a Custom Formatter.
Parameters
array $values: The values to set for the Custom Formatter.
Return value
object The Custom Formatter object.
3 calls to CustomFormattersTestCase::createCustomFormatter()
- CustomFormattersGeneralTestCase::testCustomFormattersEngineFormatterPreset in tests/
custom_formatters.general.test - Test the Formatter preset Engine.
- CustomFormattersGeneralTestCase::testCustomFormattersEngineHtmlToken in tests/
custom_formatters.general.test - Test the HTML + Token engine.
- CustomFormattersGeneralTestCase::testCustomFormattersEnginePhp in tests/
custom_formatters.general.test - Test the PHP Engine.
File
- tests/
custom_formatters.test, line 70 - Tests for the Custom Formatters module.
Class
- CustomFormattersTestCase
- Class CustomFormattersTestCase.
Code
protected function createCustomFormatter($values = array()) {
// Prepare the default values.
$name = $this
->randomName();
$defaults = array(
'label' => $name,
'name' => drupal_strtolower($name),
'field_types' => 'text_with_summary',
);
$values += $defaults;
// Create the Custom Formatter.
ctools_include('export');
$formatter = ctools_export_crud_new('formatters');
foreach ($values as $key => $value) {
$formatter->{$key} = $value;
}
$formatter->status = 1;
ctools_export_crud_save('formatters', $formatter);
// Flush Drupal caches.
drupal_flush_all_caches();
return $formatter;
}