diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-05-27 15:14:27 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-05-27 15:14:27 +0000 |
commit | 9669352fda5d5eef6c8114d71a30afeb1f60976b (patch) | |
tree | defa7d0a4021504f854b5c311c37171f8610ff0a /modules/contact | |
parent | 7856db0675c97d8b4a6f0c1279add29b3f51ebdf (diff) | |
download | brdo-9669352fda5d5eef6c8114d71a30afeb1f60976b.tar.gz brdo-9669352fda5d5eef6c8114d71a30afeb1f60976b.tar.bz2 |
- Patch #299137 by mr.baileys: added tests for the contact form's auto-reply.
Diffstat (limited to 'modules/contact')
-rw-r--r-- | modules/contact/contact.test | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/contact/contact.test b/modules/contact/contact.test index 9579b404a..c31b709ce 100644 --- a/modules/contact/contact.test +++ b/modules/contact/contact.test @@ -153,6 +153,47 @@ class ContactSitewideTestCase extends DrupalWebTestCase { } /** + * Test auto-reply on the site-wide contact form. + */ + function testAutoReply() { + // Create and login administrative user. + $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer site-wide contact form', 'administer permissions')); + $this->drupalLogin($admin_user); + + // Set up three categories, 2 with an auto-reply and one without. + $foo_autoreply = $this->randomString(40); + $bar_autoreply = $this->randomString(40); + $this->addCategory('foo', 'foo@example.com', $foo_autoreply, FALSE); + $this->addCategory('bar', 'bar@example.com', $bar_autoreply, FALSE); + $this->addCategory('no_autoreply', 'bar@example.com', '', FALSE); + + // Test the auto-reply for category 'foo'. + $email = $this->randomName(32) . '@example.com'; + $subject = $this->randomString(64); + $this->submitContact($this->randomName(16), $email, $subject, 1, $this->randomString(128)); + + // We are testing the auto-reply, so there should be one e-mail going to the sender. + $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'foo@example.com')); + $this->assertEqual(count($captured_emails), 1, t('Auto-reply e-mail was sent to the sender for category "foo".'), t('Contact')); + $this->assertEqual($captured_emails[0]['body'], $foo_autoreply, t('Auto-reply e-mail body is correct for category "foo".'), t('Contact')); + + // Test the auto-reply for category 'bar'. + $email = $this->randomName(32) . '@example.com'; + $this->submitContact($this->randomName(16), $email, $this->randomString(64), 2, $this->randomString(128)); + + // Auto-reply for category 'bar' should result in one auto-reply e-mail to the sender. + $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'bar@example.com')); + $this->assertEqual(count($captured_emails), 1, t('Auto-reply e-mail was sent to the sender for category "bar".'), t('Contact')); + $this->assertEqual($captured_emails[0]['body'], $bar_autoreply, t('Auto-reply e-mail body is correct for category "bar".'), t('Contact')); + + // Verify that no auto-reply is sent when the auto-reply field is left blank. + $email = $this->randomName(32) . '@example.com'; + $this->submitContact($this->randomName(16), $email, $this->randomString(64), 3, $this->randomString(128)); + $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'no_autoreply@example.com')); + $this->assertEqual(count($captured_emails), 0, t('No auto-reply e-mail was sent to the sender for category "no-autoreply".'), t('Contact')); + } + + /** * Add a category. * * @param string $category Name of category. |