You are here

public function FeedsMapperTaxonomyTestCase::setUp in Feeds 7.2

Same name and namespace in other branches
  1. 6 tests/feeds_mapper_taxonomy.test \FeedsMapperTaxonomyTestCase::setUp()
  2. 7 tests/feeds_mapper_taxonomy.test \FeedsMapperTaxonomyTestCase::setUp()

Sets up a Drupal site for running functional and integration tests.

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides FeedsWebTestCase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

tests/feeds_mapper_taxonomy.test, line 27
Contains FeedsMapperTaxonomyTestCase.

Class

FeedsMapperTaxonomyTestCase
Test case for taxonomy mapper mappers/taxonomy.inc.

Code

public function setUp() {
  parent::setUp();

  // Add Tags vocabulary.
  $edit = array(
    'name' => 'Tags',
    'machine_name' => 'tags',
  );
  $this
    ->drupalPost('admin/structure/taxonomy/add', $edit, 'Save');
  $edit = array(
    'name' => 'term1',
  );
  $this
    ->drupalPost('admin/structure/taxonomy/tags/add', $edit, t('Save'));
  $this
    ->assertText('Created new term term1.');

  // Create term reference field.
  $field = array(
    'field_name' => 'field_tags',
    'type' => 'taxonomy_term_reference',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
    'settings' => array(
      'allowed_values' => array(
        array(
          'vocabulary' => 'tags',
          'parent' => 0,
        ),
      ),
    ),
  );
  field_create_field($field);

  // Add a term reference field to the "article" node bundle. Tests use this
  // content type as "feed item": tests imports nodes of this type.
  $this->article_tags = array(
    'field_name' => 'field_tags',
    'bundle' => 'article',
    'entity_type' => 'node',
    'widget' => array(
      'type' => 'options_select',
    ),
    'display' => array(
      'default' => array(
        'type' => 'taxonomy_term_reference_link',
      ),
    ),
  );
  field_create_instance($this->article_tags);

  // Add a term reference field to the "page" node bundle. Tests use this
  // content type as "feed node type": this type is used to attach importers
  // to.
  $this->page_tags = array(
    'field_name' => 'field_tags',
    'bundle' => 'page',
    'entity_type' => 'node',
    'widget' => array(
      'type' => 'options_select',
    ),
    'display' => array(
      'default' => array(
        'type' => 'taxonomy_term_reference_link',
      ),
    ),
  );
  field_create_instance($this->page_tags);

  // Create an importer configuration with basic mapping.
  $this
    ->createImporterConfiguration('Syndication', 'syndication');
  $this
    ->addMappings('syndication', array(
    0 => array(
      'source' => 'title',
      'target' => 'title',
    ),
    1 => array(
      'source' => 'description',
      'target' => 'body',
    ),
    2 => array(
      'source' => 'timestamp',
      'target' => 'created',
    ),
    3 => array(
      'source' => 'url',
      'target' => 'url',
      'unique' => TRUE,
    ),
    4 => array(
      'source' => 'guid',
      'target' => 'guid',
      'unique' => TRUE,
    ),
  ));
}