From b0108a658abf718ebf14cc86208a7ff39a9c1251 Mon Sep 17 00:00:00 2001
From: Chris Leppanen <chris.leppanen@gmail.com>
Date: Wed, 29 Jan 2014 21:12:54 -0500
Subject: [PATCH] Issue #2178563 by twistor | alibama: Entityform does not seem
 to work.

---
 feeds.info                        |  1 +
 plugins/FeedsEntityProcessor.inc  |  4 +--
 tests/feeds_processor_entity.test | 56 +++++++++++++++++++++++++++++++
 tests/feeds_tests.info            |  2 +-
 4 files changed, 60 insertions(+), 3 deletions(-)
 create mode 100644 tests/feeds_processor_entity.test

diff --git a/feeds.info b/feeds.info
index fbb66b18..2ab71dc0 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 cadc8b3c..e5f924d9 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 00000000..f2cf61b6
--- /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 98a88ea6..0e1d123a 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
-- 
GitLab