From 5ff68892ad2e5e67e2d76e83f6e36ccd017fb80a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 19 Mar 2013 13:39:57 -0700 Subject: [PATCH] Merge redundant code for mailbox setup to a util fn --- tests/phpunit/CiviTest/CiviSeleniumTestCase.php | 16 ++++++++++++++++ tests/phpunit/WebTest/Campaign/MailingTest.php | 17 +++++------------ .../WebTest/Generic/GeneralClickAroundTest.php | 7 +------ .../WebTest/Mailing/AddMessageTemplateTest.php | 7 +------ tests/phpunit/WebTest/Mailing/MailingTest.php | 7 +------ 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index eae051ef3a..e3d88036cd 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -1774,6 +1774,22 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); } + /** + * Ensure we have a default mailbox set up for CiviMail + */ + function setupDefaultMailbox() { + $this->openCiviPage('admin/mailSettings', 'action=update&id=1&reset=1'); + // Check if it hasn't already been set up + if (!$this->getSelectedValue('protocol')) { + $this->type('name', 'Test Domain'); + $this->select('protocol', "IMAP"); + $this->type('server', 'localhost'); + $this->type('domain', 'example.com'); + $this->click('_qf_MailSettings_next-top'); + $this->waitForPageToLoad($this->getTimeoutMsec()); + } + } + /** * Determine the default time-out in milliseconds. * diff --git a/tests/phpunit/WebTest/Campaign/MailingTest.php b/tests/phpunit/WebTest/Campaign/MailingTest.php index e288558e76..edb2a915b8 100644 --- a/tests/phpunit/WebTest/Campaign/MailingTest.php +++ b/tests/phpunit/WebTest/Campaign/MailingTest.php @@ -37,11 +37,12 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { $this->webtestLogin('admin'); // Enable CiviCampaign module if necessary - $this->enableComponents(array('CiviCampaign')); + $this->enableComponents(array('CiviMail', 'CiviCampaign')); - // add the required Drupal permission - $permissions = array('edit-2-administer-civicampaign'); - $this->changePermissions($permissions); + $this->setupDefaultMailbox(); + + // add the required permission + $this->changePermissions('edit-2-administer-civicampaign'); // Log in as normal user $this->webtestLogin(); @@ -112,14 +113,6 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { $this->select("group_id", "$groupName"); $this->click("_qf_GroupContact_next"); - // configure default mail-box - $this->openCiviPage('admin/mailSettings', 'action=update&id=1&reset=1', '_qf_MailSettings_cancel-bottom'); - $this->type('name', 'Test Domain'); - $this->type('domain', 'example.com'); - $this->select('protocol', 'value=1'); - $this->click('_qf_MailSettings_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->openCiviPage('mailing/send', 'reset=1', '_qf_Group_cancel'); //-------select recipients---------- diff --git a/tests/phpunit/WebTest/Generic/GeneralClickAroundTest.php b/tests/phpunit/WebTest/Generic/GeneralClickAroundTest.php index bc24d359d5..9592101b32 100644 --- a/tests/phpunit/WebTest/Generic/GeneralClickAroundTest.php +++ b/tests/phpunit/WebTest/Generic/GeneralClickAroundTest.php @@ -195,12 +195,7 @@ class WebTest_Generic_GeneralClickAroundTest extends CiviSeleniumTestCase { $this->enableComponents("CiviMail"); // configure default mail-box - $this->openCiviPage("admin/mailSettings", "action=update&id=1&reset=1", "_qf_MailSettings_cancel-bottom"); - $this->type('name', 'Test Domain'); - $this->type('domain', 'example.com'); - $this->select('protocol', 'value=1'); - $this->click('_qf_MailSettings_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->setupDefaultMailbox(); // New Mailing Form // Use class names for menu items since li array can change based on which components are enabled diff --git a/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php b/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php index 0189f84598..3828fe9cec 100644 --- a/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php +++ b/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php @@ -112,12 +112,7 @@ class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase { $this->click("_qf_GroupContact_next"); // configure default mail-box - $this->openCiviPage("admin/mailSettings", "action=update&id=1&reset=1", '_qf_MailSettings_cancel-bottom'); - $this->type('name', 'Test Domain'); - $this->type('domain', 'example.com'); - $this->select('protocol', 'value=1'); - $this->click('_qf_MailSettings_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->setupDefaultMailbox(); $this->openCiviPage("mailing/send", "reset=1", "_qf_Group_cancel"); diff --git a/tests/phpunit/WebTest/Mailing/MailingTest.php b/tests/phpunit/WebTest/Mailing/MailingTest.php index 3151fbb53a..f605b8c539 100644 --- a/tests/phpunit/WebTest/Mailing/MailingTest.php +++ b/tests/phpunit/WebTest/Mailing/MailingTest.php @@ -79,12 +79,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->waitForElementPresent("_qf_GroupContact_next"); // configure default mail-box - $this->openCiviPage("admin/mailSettings", "action=update&id=1&reset=1", '_qf_MailSettings_cancel-bottom'); - $this->type('name', 'Test Domain'); - $this->type('domain', 'example.com'); - $this->select('protocol', 'value=1'); - $this->click('_qf_MailSettings_next-bottom'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->setupDefaultMailbox(); $this->openCiviPage("mailing/send", "reset=1", "_qf_Group_cancel"); -- 2.25.1