public function FeedsTamperUIWebTestCase::_testCSV in Feeds Tamper 6
1 call to FeedsTamperUIWebTestCase::_testCSV()
- FeedsTamperUIWebTestCase::testBasic in feeds_tamper_ui/
tests/ feeds_tamper_ui.test
File
- feeds_tamper_ui/
tests/ feeds_tamper_ui.test, line 142 - Tests for feeds_tamper_ui.module.
Class
- FeedsTamperUIWebTestCase
- Test Feeds Tamper UI.
Code
public function _testCSV() {
$importer = $this
->randomName();
$importer_name = $this
->randomString();
// Set up an importer.
$this
->createImporterConfiguration($importer_name, $importer);
// Set and configure plugins and mappings.
$this
->setPlugin($importer, 'FeedsCSVParser');
// We have a space in the source cause that was a problem at one point.
$mappings = array(
0 => array(
'source' => 'a Title',
'target' => 'title',
),
1 => array(
'source' => 'a Body',
'target' => 'body',
),
2 => array(
'source' => 'a GUID',
'target' => 'guid',
'unique' => TRUE,
),
);
$this
->addMappings($importer, $mappings);
// Set update existing.
$this
->setSettings($importer, 'FeedsNodeProcessor', array(
'update_existing' => 1,
));
// Test basic plugin adding.
$settings = array(
'settings[mode]' => 0,
);
$id = $this
->addTamperPlugin($importer, 'a Title', 'convert_case', $settings);
$id2 = $this
->addTamperPlugin($importer, 'a Body', 'convert_case', $settings);
$path = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds_tamper') . '/tests/feeds_tamper/';
$nid = $this
->createFeedNode($importer, $path . 'csv_test.csv', 'Testing CSV Parser');
$this
->assertText('Page Testing CSV Parser has been created.');
$this
->assertText('Created 2 Story nodes.');
$this
->drupalGet('node');
$this
->assertText('HELLO WORLD');
$this
->assertText('THIS IS A GREAT BODY.');
$this
->assertText('WORLD DOES NOT RESPOND');
$this
->assertText('THIS IS A SAD BODY.');
$this
->disableTamperPlugin($id);
$this
->disableTamperPlugin($id2);
$this
->drupalPost('node/' . $nid . '/import', array(), 'Import');
$this
->assertText('Updated 2 Story nodes.');
$this
->drupalGet('node');
$this
->assertText('Hello world');
$this
->assertText('This is a great body.');
$this
->assertText('World does not respond');
$this
->assertText('This is a sad body.');
$this
->toggleTamperPlugin($importer, 'a Title', $id);
$this
->toggleTamperPlugin($importer, 'a Body', $id2);
}