? the.patch
? pm_block_user/pm_block_user.test.save
Index: pm_block_user/pm_block_user.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/pm_block_user/pm_block_user.test,v
retrieving revision 1.9
diff -u -p -r1.9 pm_block_user.test
--- pm_block_user/pm_block_user.test	25 Dec 2010 15:27:19 -0000	1.9
+++ pm_block_user/pm_block_user.test	25 Apr 2011 23:15:45 -0000
@@ -22,6 +22,41 @@ class PrivatemsgBlockUserCase extends Dr
     parent::setUp('privatemsg', 'pm_block_user');
   }
 
+  function testRoleBlockRecipient() {
+    $author_user = $this->drupalCreateUser(array('write privatemsg', 'read privatemsg', 'access user profiles'));        // rid 3
+    $blocked_user = $this->drupalCreateUser(array('write privatemsg', 'read privatemsg', 'access user profiles'));          // rid 4
+    $admin_user = $this->drupalCreateUser(array('administer privatemsg settings'));          // rid 5
+
+    // login the admin user and set up the role blocking rules
+    $this->drupalLogin($admin_user);
+    $this->drupalGet('admin/settings/messages/block');
+    $this->drupalPost(NULL, array(), 'edit-pm-block-actions-more');       // doesn't work
+
+    $this->assertNoText('No rules have been added', 'The block form now allows adding rules');      // if this fails we still have the default empty block user form.
+
+    $edit = array(
+      'block_actions[0][author]' => 3,            // if author role is 3
+      'block_actions[0][recipient]' => 4,         // and recipent role is 4
+      'block_actions[0][action]' => 1,            // disallow sending of messages
+      'block_actions[0][enabled]' => 1            // and enable this rule
+    );
+    $this->drupalPost('admin/settings/messages/block', $edit, 'edit-submit-form');
+
+    // Verify that the user doesn't show up in the autocomplete.
+    // login the user that will try to write a message to the user with the blocked role
+    $this->drupalLogin($author_user);
+    $this->drupalGet('messages/new');
+    $this->assertText(t('Write new message'), "Searching user can write messages.");
+
+    $this->drupalGet('messages/autocomplete/' . $blocked_user->name);
+    $this->assertNoText($blocked_user->name, "User with blocked role does not appear in autocomplete results");
+
+    // todo: Verify that profile link is not shown anymore
+
+    // todo: Verify that it is not possible to manually write a message
+  }
+
+
   function testBlockAndUnblock() {
     // Create needed users.
     $user1 = $this->drupalCreateUser(array('write privatemsg', 'read privatemsg', 'access user profiles'));
@@ -138,4 +173,4 @@ class PrivatemsgBlockUserCase extends Dr
     $this->clickLink($subject);
     $this->assertNoText($reply);
   }
-}
\ No newline at end of file
+}
