From bf49063664b990908c1c0d2447f8efecc009e2a1 Mon Sep 17 00:00:00 2001 From: Chris Leppanen <chris.leppanen@gmail.com> Date: Wed, 15 Jan 2014 20:37:41 -0500 Subject: [PATCH] Issue #2174303 by twistor | bdanin: Feeds importer importer -- context and mapping not working. --- feeds_ui/feeds_ui.admin.inc | 1 + feeds_ui/feeds_ui.test | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/feeds_ui/feeds_ui.admin.inc b/feeds_ui/feeds_ui.admin.inc index eb1ff636..53a07726 100644 --- a/feeds_ui/feeds_ui.admin.inc +++ b/feeds_ui/feeds_ui.admin.inc @@ -1185,6 +1185,7 @@ function feeds_ui_importer_import_submit($form, &$form_state) { $save = feeds_importer($importer->id); $save->setConfig($importer->config); foreach (array('fetcher', 'parser', 'processor') as $type) { + $save->setPlugin($importer->config[$type]['plugin_key']); $save->$type->setConfig($importer->config[$type]['config']); } $save->save(); diff --git a/feeds_ui/feeds_ui.test b/feeds_ui/feeds_ui.test index d1e1a845..4b90a6d7 100644 --- a/feeds_ui/feeds_ui.test +++ b/feeds_ui/feeds_ui.test @@ -17,6 +17,10 @@ class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase { ); } + public function setUp() { + parent::setUp(array('php'), array('use PHP for settings')); + } + /** * UI functionality tests on * feeds_ui_overview(), @@ -111,4 +115,46 @@ class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase { // @todo Refreshing/deleting feed items. Needs to live in feeds.test } + + public function testImporterImport() { + $name = $this->randomString(); + $id = drupal_strtolower($this->randomName()); + $this->createImporterConfiguration($name, $id); + $this->setPlugin($id, 'FeedsCSVParser'); + $this->setPlugin($id, 'FeedsFileFetcher'); + $this->setPlugin($id, 'FeedsTermProcessor'); + + $this->setSettings($id, 'FeedsFileFetcher', array('allowed_extensions' => 'xml')); + $this->setSettings($id, 'FeedsCSVParser', array('delimiter' => '|')); + $this->setSettings($id, 'FeedsUserProcessor', array('skip_hash_check' => TRUE)); + + $this->drupalGet('admin/structure/feeds/' . $id . '/export'); + + $export = $this->xpath('//textarea[1]/text()'); + $export = (string) $export[0]; + + // Delete this importer. + $this->drupalPost('admin/structure/feeds/' . $id . '/delete', array(), t('Delete')); + + // Try to import. + $this->drupalPost('admin/structure/feeds/import', array('importer' => $export), t('Import')); + + $this->assertText("Successfully imported the $id feeds importer."); + + // Check that the settings are correct. + $importer = feeds_importer($id); + $this->assertEqual('FeedsFileFetcher', get_class($importer->fetcher)); + $this->assertEqual('FeedsCSVParser', get_class($importer->parser)); + $this->assertEqual('FeedsTermProcessor', get_class($importer->processor)); + + $config = $importer->fetcher->getConfig(); + $this->assertEqual('xml', $config['allowed_extensions']); + + $config = $importer->parser->getConfig(); + $this->assertEqual('|', $config['delimiter']); + + $config = $importer->processor->getConfig(); + $this->assertTrue($config['skip_hash_check']); + } + } -- GitLab