5 * Tests for plugins/FeedsTermProcessor.inc
8 // Require FeedsWebTestCase class definition.
9 require_once(dirname(__FILE__
) .
'/feeds.test.inc');
12 * Test aggregating a feed as data records.
14 class FeedsCSVtoTermsTest
extends FeedsWebTestCase
{
19 public
function getInfo() {
21 'name' => t('CSV import to taxonomy'),
22 'description' => t('Tests a standalone import configuration that uses file fetcher and CSV parser to import taxonomy terms from a CSV file.'),
23 'group' => t('Feeds'),
30 public
function setUp() {
31 parent
::setUp('taxonomy', 'ctools', 'feeds', 'feeds_ui', 'job_scheduler');
34 $this->drupalCreateUser(
36 'administer feeds', 'administer taxonomy',
43 * Test node creation, refreshing/deleting feeds and feed items.
45 public
function test() {
47 // Create an importer.
48 $this->createImporterConfiguration('Term import', 'term_import');
50 // Set and configure plugins and mappings.
51 $this->setPlugin('term_import', 'FeedsFileFetcher');
52 $this->setPlugin('term_import', 'FeedsCSVParser');
53 $this->setPlugin('term_import', 'FeedsTermProcessor');
61 $this->addMappings('term_import', $mappings);
63 // Use standalone form.
67 $this->drupalPost('admin/structure/feeds/edit/term_import/settings', $edit, 'Save');
70 'name' => 'Addams vocabulary',
71 'machine_name' => 'addams',
73 $this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
76 'vocabulary' => 'addams',
78 $this->drupalPost('admin/structure/feeds/edit/term_import/settings/FeedsTermProcessor', $edit, t('Save'));
81 $this->importFile('term_import', $this->absolutePath() .
'/tests/feeds/users.csv');
82 $this->assertText('Created 5 terms in Addams vocabulary.');
83 $this->drupalGet('admin/structure/taxonomy/addams');
84 $this->assertText('Morticia');
85 $this->assertText('Fester');
86 $this->assertText('Gomez');
87 $this->assertText('Pugsley');
90 $this->importFile('term_import', $this->absolutePath() .
'/tests/feeds/users.csv');
91 $this->assertText('There are no new terms.');
93 // Add a term manually, delete all terms, this term should still stand.
95 'name' => 'Cousin Itt',
97 $this->drupalPost('admin/structure/taxonomy/addams/add', $edit, t('Save'));
98 $this->drupalPost('import/term_import/delete-items', array(), t('Delete'));
99 $this->drupalGet('admin/structure/taxonomy/addams');
100 $this->assertText('Cousin Itt');
101 $this->assertNoText('Morticia');
102 $this->assertNoText('Fester');
103 $this->assertNoText('Gomez');
104 $this->assertNoText('Pugsley');