source: sipes/modules_contrib/feeds/tests/feeds_processor_term.test @ 92213c1

stableversion-3.0
Last change on this file since 92213c1 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100755
File size: 2.6 KB
Línea 
1<?php
2module_load_include('test', 'feeds', 'tests/feeds');
3
4/**
5 * @file
6 * Tests for plugins/FeedsTermProcessor.inc
7 */
8
9/**
10 * Test aggregating a feed as data records.
11 */
12class FeedsCSVtoTermsTest extends FeedsWebTestCase {
13  public static function getInfo() {
14    return array(
15      'name' => 'CSV import to taxonomy',
16      'description' => 'Tests a standalone import configuration that uses file fetcher and CSV parser to import taxonomy terms from a CSV file.',
17      'group' => 'Feeds',
18    );
19  }
20
21  /**
22   * Test node creation, refreshing/deleting feeds and feed items.
23   */
24  public function test() {
25
26    // Create an importer.
27    $this->createImporterConfiguration('Term import', 'term_import');
28
29    // Set and configure plugins and mappings.
30    $this->setPlugin('term_import', 'FeedsFileFetcher');
31    $this->setPlugin('term_import', 'FeedsCSVParser');
32    $this->setPlugin('term_import', 'FeedsTermProcessor');
33    $mappings = array(
34      '0' => array(
35        'source' => 'name',
36        'target' => 'name',
37        'unique' => 1,
38      ),
39    );
40    $this->addMappings('term_import', $mappings);
41
42    // Use standalone form.
43    $edit = array(
44      'content_type' => '',
45    );
46    $this->drupalPost('admin/build/feeds/edit/term_import/settings', $edit, 'Save');
47
48    $edit = array(
49      'name' => 'Addams vocabulary',
50    );
51    $this->drupalPost('admin/content/taxonomy/add/vocabulary', $edit, t('Save'));
52
53    $edit = array(
54      'vocabulary' => 1,
55    );
56    $this->drupalPost('admin/build/feeds/edit/term_import/settings/FeedsTermProcessor', $edit, t('Save'));
57
58    // Import and assert.
59    $this->importFile('term_import', $this->absolutePath() .'/tests/feeds/users.csv');
60    $this->assertText('Created 5 terms in Addams vocabulary.');
61    $this->drupalGet('admin/content/taxonomy/1');
62    $this->assertText('Fester');
63    $this->assertText('Gomez');
64    $this->assertText('Morticia');
65    $this->assertText('Pugsley');
66    $this->assertText('Wednesday');
67
68    // Import again.
69    $this->importFile('term_import', $this->absolutePath() .'/tests/feeds/users.csv');
70    $this->assertText('There are no new terms.');
71
72    // Add a term manually, delete all terms, this term should still stand.
73    $edit = array(
74      'name' => 'Cousin Itt',
75    );
76    $this->drupalPost('admin/content/taxonomy/1/add/term', $edit, t('Save'));
77    $this->drupalPost('import/term_import/delete-items', array(), t('Delete'));
78    $this->drupalGet('admin/content/taxonomy/1');
79    $this->assertText('Cousin Itt');
80    $this->assertNoText('Morticia');
81    $this->assertNoText('Fester');
82    $this->assertNoText('Gomez');
83    $this->assertNoText('Pugsley');
84    $this->assertNoText('Wednesday');
85  }
86}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.