protected function PropertiesTemplateBaseTestCase::createTemplate in Dynamic properties 7
Create a template with categories through the administration interface.
Parameters
$name: machine_name of template, a random name is generated when left empty.
$label: Label of the template, a random label is generated when left empty.
$attributes: An array of categories, that is added to the template.
Return value
Loaded category object.
1 call to PropertiesTemplateBaseTestCase::createTemplate()
- PropertiesTemplateTestCase::testPropertyFieldCreation in properties_template/
properties_template.test - Create a content based on a template.
File
- properties_template/
properties_template.test, line 63 - Contains tests for the properties_template.module
Class
- PropertiesTemplateBaseTestCase
- Base class for properties tests, provides helper methods.
Code
protected function createTemplate($name = NULL, $label = NULL, $categories = array()) {
$template = array(
'name' => empty($name) ? drupal_strtolower($this
->randomName(8)) : $name,
'label' => empty($label) ? $this
->randomName(20) : $label,
);
$this
->drupalPost('admin/config/content/properties/templates/add', $template, t('Add another category'));
for ($i = 0; $i < count($categories); $i++) {
$newAttribute = array(
"categories[{$i}][category]" => $categories[$i]->name,
);
$this
->drupalPost(NULL, $newAttribute, t('Add another category'));
}
$this
->drupalPost(NULL, NULL, t('Save'));
$template_object = properties_template_load($template['name']);
$this
->assertEqual($template_object->label, $template['label']);
return $template_object;
}