public function FeedsTamperUIWebTestCase::testCSV in Feeds Tamper 7
Same name and namespace in other branches
- 8.2 legacy/feeds_tamper_ui/tests/feeds_tamper_ui.test \FeedsTamperUIWebTestCase::testCSV()
File
- feeds_tamper_ui/
tests/ feeds_tamper_ui.test, line 150 - Tests for feeds_tamper_ui.module.
Class
- FeedsTamperUIWebTestCase
- Test Feeds Tamper UI.
Code
public function testCSV() {
$importer_name = $this
->randomName();
$importer_id = drupal_strtolower($importer_name);
// Set up an importer.
$this
->createImporterConfiguration($importer_name, $importer_id);
// Set and configure plugins and mappings.
$this
->setPlugin($importer_id, 'FeedsCSVParser');
// We have a space in the source cause that was a problem at one point.
$mappings = array(
0 => array(
'source' => 'a /T~!@#$%^&*()_+`<>;:itle✈',
'target' => 'title',
),
1 => array(
// The period is intentional.
'source' => 'a Body.',
'target' => 'body',
),
2 => array(
'source' => 'a GUID',
'target' => 'guid',
'unique' => TRUE,
),
);
$this
->addMappings($importer_id, $mappings);
// Set update existing.
$this
->setSettings($importer_id, 'FeedsNodeProcessor', array(
'update_existing' => 1,
));
// Test basic plugin adding. Use the literal UI to verify things work.
$this
->drupalGet('admin/structure/feeds/' . $importer_id . '/tamper');
$this
->clickLink(t('Add plugin'));
$this
->drupalPost(NULL, array(
'plugin_id' => 'convert_case',
), t('Choose'));
$this
->drupalPost(NULL, array(
'settings[mode]' => 0,
), t('Add'));
$this
->drupalGet('admin/structure/feeds/' . $importer_id . '/tamper');
$this
->clickLink(t('Add plugin'), 1);
$this
->drupalPost(NULL, array(
'plugin_id' => 'convert_case',
), t('Choose'));
$this
->drupalPost(NULL, array(
'settings[mode]' => 0,
), t('Add'));
$path = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds_tamper') . '/tests/feeds_tamper/';
$nid = $this
->createFeedNode($importer_id, $path . 'csv_test.csv', 'Testing CSV Parser');
$this
->assertText('Basic page Testing CSV Parser has been created.');
$this
->assertText('Created 2 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.');
$edit = array(
'0[table][' . $importer_id . '-' . feeds_tamper_make_machine('a /T~!@#$%^&*()_+`<>;:itle✈') . '-convert_case][enabled]' => FALSE,
'1[table][' . $importer_id . '-' . feeds_tamper_make_machine('a Body.') . '-convert_case][enabled]' => FALSE,
);
$this
->drupalPost('admin/structure/feeds/' . $importer_id . '/tamper', $edit, t('Save'));
$this
->drupalPost('node/' . $nid . '/import', array(), 'Import');
$this
->assertText('Updated 2 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.');
}