Stripping CVS keywords
[project/feeds.git] / tests / feeds_processor_term.test
1 <?php
2
3 /**
4 * @file
5 * Tests for plugins/FeedsTermProcessor.inc
6 */
7
8 // Require FeedsWebTestCase class definition.
9 require_once(dirname(__FILE__) .'/feeds.test.inc');
10
11 /**
12 * Test aggregating a feed as data records.
13 */
14 class FeedsCSVtoTermsTest extends FeedsWebTestCase {
15
16 /**
17 * Describe this test.
18 */
19 public function getInfo() {
20 return array(
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'),
24 );
25 }
26
27 /**
28 * Set up test.
29 */
30 public function setUp() {
31 parent::setUp('taxonomy', 'ctools', 'feeds', 'feeds_ui', 'job_scheduler');
32
33 $this->drupalLogin(
34 $this->drupalCreateUser(
35 array(
36 'administer feeds', 'administer taxonomy',
37 )
38 )
39 );
40 }
41
42 /**
43 * Test node creation, refreshing/deleting feeds and feed items.
44 */
45 public function test() {
46
47 // Create an importer.
48 $this->createImporterConfiguration('Term import', 'term_import');
49
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');
54 $mappings = array(
55 '0' => array(
56 'source' => 'name',
57 'target' => 'name',
58 'unique' => 1,
59 ),
60 );
61 $this->addMappings('term_import', $mappings);
62
63 // Use standalone form.
64 $edit = array(
65 'content_type' => '',
66 );
67 $this->drupalPost('admin/structure/feeds/edit/term_import/settings', $edit, 'Save');
68
69 $edit = array(
70 'name' => 'Addams vocabulary',
71 'machine_name' => 'addams',
72 );
73 $this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
74
75 $edit = array(
76 'vocabulary' => 'addams',
77 );
78 $this->drupalPost('admin/structure/feeds/edit/term_import/settings/FeedsTermProcessor', $edit, t('Save'));
79
80 // Import and assert.
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');
88
89 // Import again.
90 $this->importFile('term_import', $this->absolutePath() .'/tests/feeds/users.csv');
91 $this->assertText('There are no new terms.');
92
93 // Add a term manually, delete all terms, this term should still stand.
94 $edit = array(
95 'name' => 'Cousin Itt',
96 );
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');
105 }
106 }