public function PropertiesTemplateTestCase::testAdministration in Dynamic properties 7
Creates two different categories, adds them to a template and checks if the data is correctly displayed and stored.
File
- properties_template/
properties_template.test, line 107 - Contains tests for the properties_template.module
Class
- PropertiesTemplateTestCase
- Tests for fields integration.
Code
public function testAdministration() {
$this
->loginAdmin();
// Create the categories first
$attributes = array();
for ($i = 0; $i < 3; $i++) {
$attributes[$i] = $this
->createAttribute();
}
// Create category with these existing attributes.
$category1 = $this
->createCategory(drupal_strtolower($this
->randomName(8)), $this
->randomName(20), $attributes);
$attributes = array();
for ($i = 0; $i < 4; $i++) {
$attributes[$i] = $this
->createAttribute();
}
// Create category with these existing attributes.
$category2 = $this
->createCategory(drupal_strtolower($this
->randomName(8)), $this
->randomName(20), $attributes);
$template_name = drupal_strtolower($this
->randomName(8));
$template_label = $this
->randomName(20);
// Add category1
$template_form = array(
'name' => $template_name,
'label' => $template_label,
'categories[0][category]' => $category1->name,
);
$this
->drupalPost('admin/config/content/properties/templates/add', $template_form, t('Add another category'));
// check if the label of the added category1 occurs
$this
->assertText($category1->label);
// add category2
$template_form = array(
'categories[1][category]' => $category2->name,
);
$this
->drupalPost(NULL, $template_form, t('Add another category'));
// check if the label of the added category2 occurs
$this
->assertText($category2->label);
// Click add
$this
->drupalPost(NULL, NULL, t('Save'));
// look if the new generated template occurs in the list
$this
->drupalGet('admin/config/content/properties/templates');
$this
->assertText($template_name);
$this
->assertText($template_label);
// look if the template was stored in the db
$template_object = properties_template_load($template_name);
$this
->assertEqual($template_object->label, $template_label);
}