Index: tests/feedapi_mapper.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedapi_mapper/tests/feedapi_mapper.test,v
retrieving revision 1.2.2.2
diff -u -p -r1.2.2.2 feedapi_mapper.test
--- tests/feedapi_mapper.test	12 Aug 2009 09:57:37 -0000	1.2.2.2
+++ tests/feedapi_mapper.test	17 Aug 2009 11:41:25 -0000
@@ -60,6 +60,62 @@ class FeedApiMapperBasicTestCase extends
     $this->drupalLogout();
   }
 
+  function testUserInterface() {
+    $this->drupalLogin($this->admin_user);
+    $this->enableParsers(TRUE, FALSE);
+    $options = array(
+      'typename' => 'story',
+      'filename' => 'drupal.xml',
+      'mappers' => array('node', 'feedapi_node'),
+      'mapping' => array(
+        serialize(array('title')) => serialize(array('node', 'title')),
+        serialize(array('description')) => serialize(array('node', 'body')),
+        serialize(array('options', 'original_url')) => serialize(array('feedapi_node', 'original_url')),
+	serialize(array('options', 'timestamp')) => serialize(array('node', 'created')),
+      ),
+    );
+    $feed_url = $this->setupFeed($options);
+
+    // Test unique related UI
+    $this->drupalGet($feed_url . '/map');
+    $this->assertText('N/A', 'Some of the targets do not support unique bit.');
+    $this->assertText('No', 'One of the targets supports unique bit.');
+    $this->assertNoText('Yes', 'None of the targets marked unique yet.');
+    // Toggle unique bit
+    $this->clickLink('No');
+    $this->drupalGet($feed_url . '/map');
+    $this->assertText('Yes', 'One of the targets marked unique.');
+    // Checks via the database also
+    $mapper_rows = db_result(db_query("SELECT COUNT(*) FROM {feedapi_mapper}"));
+    $unique = unserialize(db_result(db_query("SELECT unique_elements FROM {feedapi_mapper}")));
+    $this->assertTrue($mapper_rows == 1, 'The mapping table contains one entry');
+    $this->assertTrue($unique[serialize(array('options', 'original_url'))], 'The mapping table contains that the URL is unique');
+
+    // Delete mapping entries
+    $mapper_entries = unserialize(db_result(db_query("SELECT mapping FROM {feedapi_mapper}")));
+    $this->assertTrue(count($mapper_entries == 4), 'Four mapping entries are defined.');
+    $this->clickLink('Delete');
+    $mapper_entries = unserialize(db_result(db_query("SELECT mapping FROM {feedapi_mapper}")));
+    $this->assertTrue(count($mapper_entries == 4), 'Three mapping entries are defined after one is deleted.');
+
+    // Test per-content-type, per-node mapping handling, overriding
+    $old_param = db_result(db_query("SELECT param FROM {feedapi_mapper}"));
+    $this->drupalGet($feed_url . '/map');
+    $this->assertText('This mapping is the standard content-type mapping.', 'The mapping is per-content-type by default');
+    $this->drupalPost($feed_url. '/map/override', array(), 'Override');
+    $this->drupalGet($feed_url . '/map');
+    $this->assertText('This mapping is specific to this feed node', 'The mapping is now per-node');
+    $mapper_rows = db_result(db_query("SELECT COUNT(*) FROM {feedapi_mapper}"));
+    $this->assertTrue($mapper_rows == 2, 'The per-node row appeared in the database table');
+    $old_mapping_before = db_fetch_array(db_query("SELECT mapping, unique_elements FROM {feedapi_mapper} WHERE param = '%s'", $old_param));
+    // Modify the per-node mapping and now it has no effect on per-content-type mapping
+    $this->clickLink('Delete');
+    $this->drupalGet($feed_url . '/map');
+    $this->clickLink('Yes');
+    $old_mapping_after = db_fetch_array(db_query("SELECT mapping, unique_elements FROM {feedapi_mapper} WHERE param = '%s'", $old_param));
+    $this->assertTrue($old_mapping_after == $old_mapping_before, 'The per-content-type mapping hasn\'t been modified');
+  }
+
   function _testDefaultMapping() {
     $options = array(
       'typename' => 'story',
