diff --git a/feeds.info b/feeds.info index fbb66b1855699f87276176a5fdf3717551092d0c..2ab71dc0228589d3ebc8ae17005540ee877dc9fc 100644 --- a/feeds.info +++ b/feeds.info @@ -41,6 +41,7 @@ files[] = tests/feeds_mapper_profile.test files[] = tests/feeds_mapper.test files[] = tests/feeds_mapper_config.test files[] = tests/feeds_fetcher_file.test +files[] = tests/feeds_processor_entity.test files[] = tests/feeds_processor_node.test files[] = tests/feeds_processor_term.test files[] = tests/feeds_processor_user.test diff --git a/plugins/FeedsEntityProcessor.inc b/plugins/FeedsEntityProcessor.inc index cadc8b3c691a3bab43227524ffdb000153043f4f..e5f924d9607bc3b439cdc6456c74e7bc6f1e45a4 100644 --- a/plugins/FeedsEntityProcessor.inc +++ b/plugins/FeedsEntityProcessor.inc @@ -60,8 +60,8 @@ class FeedsEntityProcessor extends FeedsProcessor { $info = $this->entityInfo(); $values = $this->config['values']; - if (isset($info['entity keys']['bundle']) && isset($config['bundle'])) { - $values[$info['entity keys']['bundle']] = $config['bundle']; + if (isset($info['entity keys']['bundle']) && isset($this->config['bundle'])) { + $values[$info['entity keys']['bundle']] = $this->config['bundle']; } return entity_create($this->entityType(), $values); diff --git a/tests/feeds_processor_entity.test b/tests/feeds_processor_entity.test new file mode 100644 index 0000000000000000000000000000000000000000..f2cf61b621143d0ba5bf0b46399a64a45f6e1b2c --- /dev/null +++ b/tests/feeds_processor_entity.test @@ -0,0 +1,56 @@ +<?php + +/** + * @file + * Tests for plugins/FeedsEntityProcessor.inc. + */ + +/** + * Test aggregating a feed as node items. + */ +class FeedsEntityProcessorTest extends FeedsWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'Processor: Entity', + 'description' => 'Tests importing entities using the generic processor.', + 'group' => 'Feeds', + 'dependencies' => array('entity_test'), + ); + } + + /** + * Set up test. + */ + public function setUp() { + parent::setUp(array('entity_test')); + // Create an importer configuration. + $this->createImporterConfiguration('Syndication', 'syndication'); + $this->setPlugin('syndication', 'FeedsEntityProcessorEntity_test'); + } + + /** + * Test basic entity creation. + */ + public function test() { + $bundle = drupal_strtolower($this->randomName()); + + // Create bundle entity. + entity_create('entity_test_type', array( + 'id' => drupal_strtolower($this->randomName()), + 'name' => $bundle, + ))->save(); + + $this->setSettings('syndication', 'FeedsEntityProcessorEntity_test', array( + 'bundle' => $bundle, + )); + + // Run import. + $this->createFeedNode(); + + // Assert 10 items aggregated after creation of the node. + $this->assertText('Created 10 test entity'); + $this->assertEqual(10, db_query("SELECT COUNT(*) FROM {entity_test}")->fetchField()); + } + +} diff --git a/tests/feeds_tests.info b/tests/feeds_tests.info index 98a88ea622eb81be64bb58bef1ebb3b0e7614154..0e1d123ac6caa0055653fa75b98b6cd596285b8c 100644 --- a/tests/feeds_tests.info +++ b/tests/feeds_tests.info @@ -3,5 +3,5 @@ description = "Support module for Feeds related testing." package = Testing version = VERSION core = 7.x -files[] = feeds_test.module +test_dependencies[] = entity hidden = TRUE