You are here

public function FeedsCSVtoTermsTest::test in Feeds 6

Same name and namespace in other branches
  1. 7.2 tests/feeds_processor_term.test \FeedsCSVtoTermsTest::test()
  2. 7 tests/feeds_processor_term.test \FeedsCSVtoTermsTest::test()

Test node creation, refreshing/deleting feeds and feed items.

File

tests/feeds_processor_term.test, line 24
Tests for plugins/FeedsTermProcessor.inc

Class

FeedsCSVtoTermsTest
Test aggregating a feed as data records.

Code

public function test() {

  // Create an importer.
  $this
    ->createImporterConfiguration('Term import', 'term_import');

  // Set and configure plugins and mappings.
  $this
    ->setPlugin('term_import', 'FeedsFileFetcher');
  $this
    ->setPlugin('term_import', 'FeedsCSVParser');
  $this
    ->setPlugin('term_import', 'FeedsTermProcessor');
  $mappings = array(
    '0' => array(
      'source' => 'name',
      'target' => 'name',
      'unique' => 1,
    ),
  );
  $this
    ->addMappings('term_import', $mappings);

  // Use standalone form.
  $edit = array(
    'content_type' => '',
  );
  $this
    ->drupalPost('admin/build/feeds/edit/term_import/settings', $edit, 'Save');
  $edit = array(
    'name' => 'Addams vocabulary',
  );
  $this
    ->drupalPost('admin/content/taxonomy/add/vocabulary', $edit, t('Save'));
  $edit = array(
    'vocabulary' => 1,
  );
  $this
    ->drupalPost('admin/build/feeds/edit/term_import/settings/FeedsTermProcessor', $edit, t('Save'));

  // Import and assert.
  $this
    ->importFile('term_import', $this
    ->absolutePath() . '/tests/feeds/users.csv');
  $this
    ->assertText('Created 5 terms in Addams vocabulary.');
  $this
    ->drupalGet('admin/content/taxonomy/1');
  $this
    ->assertText('Fester');
  $this
    ->assertText('Gomez');
  $this
    ->assertText('Morticia');
  $this
    ->assertText('Pugsley');
  $this
    ->assertText('Wednesday');

  // Import again.
  $this
    ->importFile('term_import', $this
    ->absolutePath() . '/tests/feeds/users.csv');
  $this
    ->assertText('There are no new terms.');

  // Add a term manually, delete all terms, this term should still stand.
  $edit = array(
    'name' => 'Cousin Itt',
  );
  $this
    ->drupalPost('admin/content/taxonomy/1/add/term', $edit, t('Save'));
  $this
    ->drupalPost('import/term_import/delete-items', array(), t('Delete'));
  $this
    ->drupalGet('admin/content/taxonomy/1');
  $this
    ->assertText('Cousin Itt');
  $this
    ->assertNoText('Morticia');
  $this
    ->assertNoText('Fester');
  $this
    ->assertNoText('Gomez');
  $this
    ->assertNoText('Pugsley');
  $this
    ->assertNoText('Wednesday');
}