function TaxonomyTermFieldTestCase::setUp

Overrides DrupalWebTestCase::setUp

File

modules/taxonomy/taxonomy.test, line 1546

Class

TaxonomyTermFieldTestCase
Tests for taxonomy term field and formatter.

Code

function setUp() {
    parent::setUp('field_test');
    $web_user = $this->drupalCreateUser(array(
        'access field_test content',
        'administer field_test content',
        'administer taxonomy',
    ));
    $this->drupalLogin($web_user);
    $this->vocabulary = $this->createVocabulary();
    // Setup a field and instance.
    $this->field_name = drupal_strtolower($this->randomName());
    $this->field = array(
        'field_name' => $this->field_name,
        'type' => 'taxonomy_term_reference',
        'settings' => array(
            'allowed_values' => array(
                array(
                    'vocabulary' => $this->vocabulary->machine_name,
                    'parent' => '0',
                ),
            ),
        ),
    );
    field_create_field($this->field);
    $this->instance = array(
        'field_name' => $this->field_name,
        'entity_type' => 'test_entity',
        'bundle' => 'test_bundle',
        'widget' => array(
            'type' => 'options_select',
        ),
        'display' => array(
            'full' => array(
                'type' => 'taxonomy_term_reference_link',
            ),
        ),
    );
    field_create_instance($this->instance);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.