You are here

protected function PropertiesBaseTestCase::createAttribute in Dynamic properties 7

Create an attribute through the administration interface, load and return it.

Parameters

$name: machine_name of the attribute, a random name is generated when left empty.

$label: Label of the attribute, a random label is generated when left empty.

Return value

Loaded attribute object.

6 calls to PropertiesBaseTestCase::createAttribute()
PropertiesAdministrationTestCase::testCreating in ./properties.test
PropertiesAdministrationTestCase::testEditCategory in ./properties.test
Tests for creating and editing a category.
PropertiesBaseTestCase::createProperties in ./properties.test
Creates a given number of categories including attributes.
PropertiesTemplateTestCase::testAdministration in properties_template/properties_template.test
Creates two different categories, adds them to a template and checks if the data is correctly displayed and stored.
PropertiesTestCase::testAutocomplete in ./properties.test
Test autocomplete functionality.

... See full list

File

./properties.test, line 90
Contains tests for the properties.module

Class

PropertiesBaseTestCase
Base class for properties tests, provides helper methods.

Code

protected function createAttribute($name = NULL, $label = NULL) {
  $attribute = array(
    'name' => empty($name) ? drupal_strtolower($this
      ->randomName(8)) : $name,
    'label' => empty($label) ? $this
      ->randomName(20) : $label,
  );
  $this
    ->drupalPost('admin/config/content/properties/attributes/add', $attribute, t('Save'));
  $this
    ->assertText(t('Attribute created.'));
  $attribute_object = properties_attribute_load($attribute['name']);
  $this
    ->assertEqual($attribute_object->label, $attribute['label']);
  return $attribute_object;
}