From 42daf119777cf8b9cb501c44348c76a59382b40c Mon Sep 17 00:00:00 2001
From: Coleman Watts ' . ts('Your database is marked with an unexpected version number: %1. The v%2 codebase may not be compatible with your database state. You will need to determine the correct version corresponding to your current database state. You may want to revert to the codebase you were using until you resolve this problem.',
array(1 => $dbVersion, 2 => $codeVersion)
- );
- $errorMessage .= " " . ts('OR if this is an svn install, you might want to fix civicrm-version.php file.') . "
" . ts('OR if this is a manual install from git, you might want to fix civicrm-version.php file.') . "
"; return FALSE; } } diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index f9531d4d68..eae051ef3a 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -47,7 +47,8 @@ require_once CIVICRM_SETTINGS_PATH; */ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { - // protected $coverageScriptUrl = 'http://tests.dev.civicrm.org/drupal/phpunit_coverage.php'; + // Current logged-in user + protected $loggedInAs = NULL; /** * Constructor @@ -65,6 +66,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { */ function __construct($name = NULL, array$data = array(), $dataName = '', array$browser = array()) { parent::__construct($name, $data, $dataName, $browser); + $this->loggedInAs = NULL; require_once 'CiviSeleniumSettings.php'; $this->settings = new CiviSeleniumSettings(); @@ -74,6 +76,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { CRM_Core_ClassLoader::singleton()->register(); // also initialize a connection to the db + // FIXME: not necessary for most tests, consider moving into functions that need this $config = CRM_Core_Config::singleton(); } @@ -85,23 +88,44 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } protected function tearDown() { - // $this->open( $this->settings->sandboxPATH . "logout?reset=1"); } /** * Authenticate as drupal user - * @param $admin: (bool) use admin user/pass instead of normal user + * @param $user: (str) the key 'user' or 'admin', or a literal username + * @param $pass: (str) if $user is a literal username and not 'user' or 'admin', supply the password */ - function webtestLogin($admin = FALSE) { + function webtestLogin($user = 'user', $pass = NULL) { + // If already logged in as correct user, do nothing + if ($this->loggedInAs === $user) { + return; + } + // If we are logged in as a different user, log out first + if ($this->loggedInAs) { + $this->webtestLogout(); + } $this->open("{$this->sboxPath}user"); - $password = $admin ? $this->settings->adminPassword : $this->settings->password; - $username = $admin ? $this->settings->adminUsername : $this->settings->username; + // Lookup username & password if not supplied + $username = $user; + if ($pass === NULL) { + $pass = $user == 'admin' ? $this->settings->adminPassword : $this->settings->password; + $username = $user == 'admin' ? $this->settings->adminUsername : $this->settings->username; + } // Make sure login form is available $this->waitForElementPresent('edit-submit'); $this->type('edit-name', $username); - $this->type('edit-pass', $password); + $this->type('edit-pass', $pass); $this->click('edit-submit'); $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->loggedInAs = $user; + } + + function webtestLogout() { + if ($this->loggedInAs) { + $this->open($this->sboxPath . "user/logout"); + $this->waitForPageToLoad($this->getTimeoutMsec()); + } + $this->loggedInAs = NULL; } /** @@ -131,7 +155,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } } $this->open("{$this->sboxPath}civicrm/$url"); - $this->waitForPageToLoad(); + $this->waitForPageToLoad($this->getTimeoutMsec()); if ($waitFor) { $this->waitForElementPresent($waitFor); } @@ -770,7 +794,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { // go to the New Contribution Page page $this->open($this->sboxPath . 'civicrm/admin/contribute?action=add&reset=1'); - $this->waitForPageToLoad(); + $this->waitForPageToLoad($this->getTimeoutMsec()); // fill in step 1 (Title and Settings) $this->type('title', $pageTitle); @@ -1119,8 +1143,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { 'period_type' => $period_type, ); - $this->open($this->sboxPath . 'civicrm/admin/member/membershipType/add?action=add&reset=1'); - $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); + $this->openCiviPage("admin/member/membershipType/add", "action=add&reset=1", '_qf_MembershipType_cancel-bottom'); $this->type('name', $memTypeParams['membership_type']); @@ -1206,7 +1229,6 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $firstName2 = substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name"); - // Go directly to the URL of the screen that you will be testing (Activity Tab). $this->click("css=li#tab_activity a"); // waiting for the activity dropdown to show up @@ -1372,21 +1394,9 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { return $this->assertInternalType($expected, $actual, $message); } - function changeAdminLinks() { - $version = 7; - if ($version == 7) { - $this->open("{$this->sboxPath}admin/people/permissions"); - } - else { - $this->open("{$this->sboxPath}admin/user/permissions"); - } - } - - /** * Add new Financial Account */ - function _testAddFinancialAccount($financialAccountTitle, $financialAccountDescription = FALSE, $accountingCode = FALSE, @@ -1399,7 +1409,6 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $isDefault = FALSE ) { - // Go directly to the URL $this->open($this->sboxPath . "civicrm/admin/financial/financialAccount?reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -1643,29 +1652,25 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $this->assertTrue($this->isTextPresent($text), 'Missing text: ' . $text); } - + /** + * Give the specified permissions + * Note: this function logs in as 'admin' + */ function changePermissions($permission) { - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->webtestLogin(TRUE); - $this->changeAdminLinks(); + $this->webtestLogin('admin'); + $this->open("{$this->sboxPath}admin/people/permissions"); $this->waitForElementPresent('edit-submit'); - foreach ((array) $permission as $key => $value) { - $this->check($value); + foreach ((array) $permission as $perm) { + $this->check($perm); } $this->click('edit-submit'); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertTrue($this->isTextPresent('The changes have been saved.')); - $this->open($this->sboxPath . "user/logout"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->webtestLogin(); } function addProfile($profileTitle, $profileFields) { - // Go directly to the URL of the screen that you will be testing (New Profile). - $this->open($this->sboxPath . "civicrm/admin/uf/group?reset=1"); + $this->openCiviPage('admin/uf/group', "reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click('link=Add Profile'); // Add membership custom data field to profile @@ -1762,8 +1767,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } function addPaymentInstrument($label, $financialAccount) { - $this->open($this->sboxPath . "civicrm/admin/options/payment_instrument?group=payment_instrument&action=add&reset=1"); - $this->waitForElementPresent("_qf_Options_next-bottom"); + $this->openCiviPage('admin/options/payment_instrument?group=payment_instrument&action=add', 'reset=1', "_qf_Options_next-bottom"); $this->type("label", $label); $this->select("financial_account_id", "value=$financialAccount"); $this->click("_qf_Options_next-bottom"); diff --git a/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php b/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php index 56b0df8c8c..f87490fc68 100755 --- a/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php +++ b/tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php @@ -33,10 +33,9 @@ class WebTest_ACL_AssignUsersToRolesTest extends CiviSeleniumTestCase { } function testAssignUsersToRoles() { - $this->open($this->sboxPath); $this->webtestLogin(); - // Go directly to the URL of the screen that will create new group. + $this->openCiviPage("group/add", "reset=1"); $groupTitle = "testGroup" . substr(sha1(rand()), 0, 4); $this->type("title", $groupTitle); @@ -46,7 +45,6 @@ class WebTest_ACL_AssignUsersToRolesTest extends CiviSeleniumTestCase { $this->assertElementContainsText('crm-notification-container', "The Group '{$groupTitle}' has been saved."); - // Go directly to the URL that will create a new ACL role $this->openCiviPage("admin/options/acl_role", "group=acl_role&action=add&reset=1", "_qf_Options_cancel-bottom"); $label = "TestAclRole" . substr(sha1(rand()), 0, 4); @@ -55,8 +53,6 @@ class WebTest_ACL_AssignUsersToRolesTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertElementContainsText('crm-notification-container', "The Acl Role '{$label}' has been saved"); - - // Go directly to the URL of the screen that will assign users to role. $this->openCiviPage("acl/entityrole", "action=add&reset=1"); $this->select("acl_role_id", "label=" . $label); @@ -65,8 +61,6 @@ class WebTest_ACL_AssignUsersToRolesTest extends CiviSeleniumTestCase { $this->click("_qf_EntityRole_next-botttom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - - // Go directly to the URL of the screen that will manage ACLs $this->openCiviPage("acl", "action=add&reset=1"); $this->click("group_id"); $this->select("group_id", "label={$groupTitle}"); diff --git a/tests/phpunit/WebTest/Activity/ContactContextAddTest.php b/tests/phpunit/WebTest/Activity/ContactContextAddTest.php index 606cae1b81..1650d6f364 100644 --- a/tests/phpunit/WebTest/Activity/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Activity/ContactContextAddTest.php @@ -33,13 +33,6 @@ class WebTest_Activity_ContactContextAddTest extends CiviSeleniumTestCase { } function testContactContextActivityAdd() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Log in using webtestLogin() method $this->webtestLogin(); // Adding Adding contact with randomized first name for test testContactContextActivityAdd @@ -49,7 +42,6 @@ class WebTest_Activity_ContactContextAddTest extends CiviSeleniumTestCase { $firstName2 = substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name"); - // Go directly to the URL of the screen that you will be testing (Activity Tab). $this->click("css=li#tab_activity a"); // waiting for the activity dropdown to show up @@ -57,12 +49,12 @@ class WebTest_Activity_ContactContextAddTest extends CiviSeleniumTestCase { // Select the activity type from the activity dropdown $this->select("other_activity", "label=Meeting"); + $this->waitForPageToLoad($this->getTimeoutMsec()); // waitForPageToLoad is not always reliable. Below, we're waiting for the submit // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_Activity_upload"); - // Let's start filling the form with values. // ...and verifying if the page contains properly formatted display name for chosen contact. $this->assertElementContainsText('css=tr.crm-activity-form-block-target_contact_id td ul li.token-input-token-facebook', 'Anderson, ' . $firstName2, 'Contact not found in line ' . __LINE__); diff --git a/tests/phpunit/WebTest/Activity/IcalTest.php b/tests/phpunit/WebTest/Activity/IcalTest.php index 566f1ad1c0..a0bb17009f 100644 --- a/tests/phpunit/WebTest/Activity/IcalTest.php +++ b/tests/phpunit/WebTest/Activity/IcalTest.php @@ -41,8 +41,6 @@ class WebTest_Activity_IcalTest extends CiviSeleniumTestCase { } function testStandaloneActivityAdd() { - - $this->open($this->sboxPath); $this->webtestLogin(); $this->openCivipage("admin/setting/preferences/display", "reset=1", "name=activity_assignee_notification_ics"); @@ -53,7 +51,7 @@ class WebTest_Activity_IcalTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // Start spooling emails - $mailer = new CiviMailUtils( $this, true ); + $mailer = new CiviMailUtils($this, true); self::$foundIt = false; $firstName1 = substr(sha1(rand()), 0, 7); @@ -63,8 +61,10 @@ class WebTest_Activity_IcalTest extends CiviSeleniumTestCase { $this->select("activity_type_id", "value=1"); - $this->click("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id"); - $this->typeKeys("css=tr.crm-activity-form-block-assignee_contact_id input#token-input-assignee_contact_id", "$firstName1"); + $this->click("token-input-assignee_contact_id"); + sleep(1); + $this->type("token-input-assignee_contact_id", "$firstName1"); + $this->typeKeys("token-input-assignee_contact_id", "$firstName1"); $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook"); diff --git a/tests/phpunit/WebTest/Activity/StandaloneAddTest.php b/tests/phpunit/WebTest/Activity/StandaloneAddTest.php index d91f909d44..2c9a8d4a2f 100644 --- a/tests/phpunit/WebTest/Activity/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Activity/StandaloneAddTest.php @@ -33,17 +33,6 @@ class WebTest_Activity_StandaloneAddTest extends CiviSeleniumTestCase { } function testStandaloneActivityAdd() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Adding Anderson, Anthony and Summerson, Samuel for testStandaloneActivityAdd test @@ -53,11 +42,8 @@ class WebTest_Activity_StandaloneAddTest extends CiviSeleniumTestCase { $firstName2 = substr(sha1(rand()), 0, 7); $this->webtestAddContact("$firstName2", "Summerson", $firstName2 . "@summerson.com"); - // Go directly to the URL of the screen that you will be testing (New Activity-standalone). $this->openCiviPage("activity", "reset=1&action=add&context=standalone", "_qf_Activity_upload"); - // Let's start filling the form with values. - // Select one of the options in Activity Type selector. Use option value, not label - since labels can be translated and test would fail $this->select("activity_type_id", "value=1"); diff --git a/tests/phpunit/WebTest/Admin/CustomAddTest.php b/tests/phpunit/WebTest/Admin/CustomAddTest.php index 3c9d4c9959..8d42e37bd6 100644 --- a/tests/phpunit/WebTest/Admin/CustomAddTest.php +++ b/tests/phpunit/WebTest/Admin/CustomAddTest.php @@ -33,19 +33,8 @@ class WebTest_Admin_CustomAddTest extends CiviSeleniumTestCase { } function testCustomAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (Custom data for contacts). $this->openCiviPage("admin/custom/group", "action=add&reset=1"); //fill custom group title diff --git a/tests/phpunit/WebTest/Admin/Form/ScheduleReminderTest.php b/tests/phpunit/WebTest/Admin/Form/ScheduleReminderTest.php index 9fd1f52d50..67446ab69e 100644 --- a/tests/phpunit/WebTest/Admin/Form/ScheduleReminderTest.php +++ b/tests/phpunit/WebTest/Admin/Form/ScheduleReminderTest.php @@ -33,23 +33,10 @@ class WebTest_Admin_Form_ScheduleReminderTest extends CiviSeleniumTestCase { } function testScheduleReminder() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Add new Schedule Reminder - $this->open($this->sboxPath . 'civicrm/admin/scheduleReminders?reset=1'); - $this->open($this->sboxPath . 'civicrm/admin/scheduleReminders?action=add&reset=1'); - $this->waitForElementPresent('_qf_ScheduleReminders_cancel-bottom'); + $this->openCiviPage("admin/scheduleReminders", "action=add&reset=1", '_qf_ScheduleReminders_cancel-bottom'); // Fill Title $title = 'Title' . substr(sha1(rand()), 0, 4); diff --git a/tests/phpunit/WebTest/Admin/Form/Setting/LocalizationTest.php b/tests/phpunit/WebTest/Admin/Form/Setting/LocalizationTest.php index 5ec922b933..4b549fb77b 100644 --- a/tests/phpunit/WebTest/Admin/Form/Setting/LocalizationTest.php +++ b/tests/phpunit/WebTest/Admin/Form/Setting/LocalizationTest.php @@ -33,10 +33,6 @@ class WebTest_Admin_Form_Setting_LocalizationTest extends CiviSeleniumTestCase { } function testDefaultCountryIsEnabled() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); $this->webtestLogin(); $this->open($this->sboxPath . "civicrm/admin/setting/localization?reset=1"); diff --git a/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php b/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php index 6fb88addc4..aade985eab 100644 --- a/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php +++ b/tests/phpunit/WebTest/Admin/MoveCustomDataTest.php @@ -33,16 +33,6 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { } function testCreateCustomFields() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $cid_all = $this->_createContact("all_data", "move_custom_data"); @@ -208,7 +198,7 @@ class WebTest_Admin_MoveCustomDataTest extends CiviSeleniumTestCase { //Creates a custom field group for a specific entity type and returns the custom group Id function _createCustomGroup($prefix = "custom", $entity = "Contact") { - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->openCiviPage('admin/custom/group', 'action=add&reset=1'); //fill custom group title diff --git a/tests/phpunit/WebTest/Admin/RelationshipTypeAddTest.php b/tests/phpunit/WebTest/Admin/RelationshipTypeAddTest.php index cb26c6df13..d31cbb1c46 100644 --- a/tests/phpunit/WebTest/Admin/RelationshipTypeAddTest.php +++ b/tests/phpunit/WebTest/Admin/RelationshipTypeAddTest.php @@ -34,7 +34,6 @@ class WebTest_Admin_RelationshipTypeAddTest extends CiviSeleniumTestCase { function testRelationshipTypeAdd() { - $this->open($this->sboxPath); $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -80,7 +79,6 @@ class WebTest_Admin_RelationshipTypeAddTest extends CiviSeleniumTestCase { function testRelationshipTypeAddValidateFormRules() { - $this->open($this->sboxPath); $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Campaign/ActivityTest.php b/tests/phpunit/WebTest/Campaign/ActivityTest.php index d82f11450d..4e6aceb7f0 100644 --- a/tests/phpunit/WebTest/Campaign/ActivityTest.php +++ b/tests/phpunit/WebTest/Campaign/ActivityTest.php @@ -33,7 +33,7 @@ class WebTest_Campaign_ActivityTest extends CiviSeleniumTestCase { } function testCreateCampaign() { - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); // Enable CiviCampaign module if necessary $this->enableComponents(array('CiviCampaign')); @@ -42,6 +42,9 @@ class WebTest_Campaign_ActivityTest extends CiviSeleniumTestCase { $permissions = array('edit-2-administer-civicampaign'); $this->changePermissions($permissions); + // Log in as normal user + $this->webtestLogin(); + // Create new group $title = substr(sha1(rand()), 0, 7); $groupName = $this->WebtestAddGroup(); @@ -74,10 +77,8 @@ class WebTest_Campaign_ActivityTest extends CiviSeleniumTestCase { $this->click("_qf_GroupContact_next"); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to the URL of the screen that you will be testing $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom'); - // Let's start filling the form with values. $campaignTitle = "Campaign " . $title; $this->type("title", $campaignTitle); @@ -119,7 +120,6 @@ class WebTest_Campaign_ActivityTest extends CiviSeleniumTestCase { $firstName2 = substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name"); - // Go directly to the URL of the screen that you will be testing (Activity Tab). $this->click("css=li#tab_activity a"); // waiting for the activity dropdown to show up @@ -132,7 +132,6 @@ class WebTest_Campaign_ActivityTest extends CiviSeleniumTestCase { // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_Activity_upload"); - // Let's start filling the form with values. // ...and verifying if the page contains properly formatted display name for chosen contact. $this->assertElementContainsText('css=tr.crm-activity-form-block-target_contact_id td ul li.token-input-token-facebook','Anderson, ' . $firstName2, 'Contact not found in line ' . __LINE__); diff --git a/tests/phpunit/WebTest/Campaign/CampaignDescriptionTest.php b/tests/phpunit/WebTest/Campaign/CampaignDescriptionTest.php index aabc19efa9..235c895b43 100644 --- a/tests/phpunit/WebTest/Campaign/CampaignDescriptionTest.php +++ b/tests/phpunit/WebTest/Campaign/CampaignDescriptionTest.php @@ -38,7 +38,6 @@ class WebTest_Campaign_CampaignDescriptionTest extends CiviSeleniumTestCase { function testCreateCampaign() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -52,7 +51,6 @@ class WebTest_Campaign_CampaignDescriptionTest extends CiviSeleniumTestCase { //Creating a new Campaign $this->openCivipage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom'); - // Let's start filling the form with values. $campaignTitle = "Campaign $title"; $this->type("title", $campaignTitle); diff --git a/tests/phpunit/WebTest/Campaign/MailingTest.php b/tests/phpunit/WebTest/Campaign/MailingTest.php index 0853ce0c14..e288558e76 100644 --- a/tests/phpunit/WebTest/Campaign/MailingTest.php +++ b/tests/phpunit/WebTest/Campaign/MailingTest.php @@ -34,7 +34,7 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { function testCreateCampaign() { // Log in as admin first to verify permissions for CiviCampaign - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); // Enable CiviCampaign module if necessary $this->enableComponents(array('CiviCampaign')); @@ -43,6 +43,9 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { $permissions = array('edit-2-administer-civicampaign'); $this->changePermissions($permissions); + // Log in as normal user + $this->webtestLogin(); + // Create new group $title = substr(sha1(rand()), 0, 7); $groupName = $this->WebtestAddGroup(); @@ -62,10 +65,8 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { $this->click("_qf_GroupContact_next"); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to the URL of the screen that you will be testing $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom'); - // Let's start filling the form with values. $campaignTitle = "Campaign $title"; $this->type("title", $campaignTitle); @@ -119,7 +120,6 @@ class WebTest_Campaign_MailingTest extends CiviSeleniumTestCase { $this->click('_qf_MailSettings_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to Schedule and Send Mailing form $this->openCiviPage('mailing/send', 'reset=1', '_qf_Group_cancel'); //-------select recipients---------- diff --git a/tests/phpunit/WebTest/Campaign/MembershipTest.php b/tests/phpunit/WebTest/Campaign/MembershipTest.php index deb0fe0f56..f209567819 100644 --- a/tests/phpunit/WebTest/Campaign/MembershipTest.php +++ b/tests/phpunit/WebTest/Campaign/MembershipTest.php @@ -33,17 +33,7 @@ class WebTest_Campaign_MembershipTest extends CiviSeleniumTestCase { } function testCreateCampaign() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(); + $this->webtestLogin('admin'); // Create new group $title = substr(sha1(rand()), 0, 7); @@ -81,13 +71,12 @@ class WebTest_Campaign_MembershipTest extends CiviSeleniumTestCase { $this->enableComponents(array('CiviCampaign')); // add the required Drupal permission - $permissions = array('edit-2-administer-civicampaign'); - $this->changePermissions($permissions); + $this->changePermissions('edit-2-administer-civicampaign'); - // Go directly to the URL of the screen that you will be testing + // Log in as normal user + $this->webtestLogin(); $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom'); - // Let's start filling the form with values. $campaignTitle = "Campaign $title"; $this->type("title", $campaignTitle); diff --git a/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php b/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php index d62e7f5312..4d513d37a7 100644 --- a/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php +++ b/tests/phpunit/WebTest/Campaign/OfflineContributionTest.php @@ -33,17 +33,7 @@ class WebTest_Campaign_OfflineContributionTest extends CiviSeleniumTestCase { } function testCreateCampaign() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(); + $this->webtestLogin('admin'); // Create new group $title = substr(sha1(rand()), 0, 7); @@ -80,24 +70,20 @@ class WebTest_Campaign_OfflineContributionTest extends CiviSeleniumTestCase { // Enable CiviCampaign module if necessary $this->enableComponents(array('CiviCampaign')); - // add the required Drupal permission - $permissions = array('edit-2-administer-civicampaign'); - $this->changePermissions($permissions); + // add the required permission + $this->changePermissions('edit-2-administer-civicampaign'); + + // Log in as normal user + $this->webtestLogin(); $this->openCiviPage('campaign', 'reset=1', "link=Add Campaign"); if ($this->isTextPresent('No campaigns found.')) { - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). + $this->openCiviPage('contribute/add', 'reset=1&action=add&context=standalone', '_qf_Contribution_cancel-bottom'); $this->assertElementContainsText('crm-container', 'There are currently no active Campaigns.'); } - - // Go directly to the URL of the screen that you will be testing $this->openCiviPage('campaign/add', 'reset=1'); - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - - // Let's start filling the form with values. $campaignTitle = "Campaign $title"; $this->type("title", $campaignTitle); @@ -254,10 +240,8 @@ class WebTest_Campaign_OfflineContributionTest extends CiviSeleniumTestCase { } function pastCampaignsTest($groupName) { - // Go directly to the URL of the screen that you will be testing $this->openCiviPage('campaign/add', 'reset=1', '_qf_Campaign_upload-bottom'); - // Let's start filling the form with values. $pastTitle = substr(sha1(rand()), 0, 7); $pastCampaignTitle = "Past Campaign $pastTitle"; $this->type("title", $pastCampaignTitle); diff --git a/tests/phpunit/WebTest/Campaign/OfflineEventRegistrationTest.php b/tests/phpunit/WebTest/Campaign/OfflineEventRegistrationTest.php index 291f9440d1..8e71a0e711 100644 --- a/tests/phpunit/WebTest/Campaign/OfflineEventRegistrationTest.php +++ b/tests/phpunit/WebTest/Campaign/OfflineEventRegistrationTest.php @@ -33,17 +33,7 @@ class WebTest_Campaign_OfflineEventRegistrationTest extends CiviSeleniumTestCase } function testCreateCampaign() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(); + $this->webtestLogin('admin'); // Create new group $title = substr(sha1(rand()), 0, 7); @@ -80,40 +70,20 @@ class WebTest_Campaign_OfflineEventRegistrationTest extends CiviSeleniumTestCase // Enable CiviCampaign module if necessary $this->enableComponents("CiviCampaign"); - // now logout and login with admin credentials - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - - //make sure we do have required permissions. - $this->webtestLogin(TRUE); - - // add the required Drupal permission - $permissions = array("edit-2-administer-civicampaign"); - $this->changePermissions($permissions); - - // now logout and do membership test that way - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + // add the required permission + $this->changePermissions("edit-2-administer-civicampaign"); + // Log in as normal user $this->webtestLogin(); - $this->open($this->sboxPath . 'civicrm/campaign?reset=1'); - $this->waitForElementPresent("link=Add Campaign"); + $this->openCiviPage("campaign", "reset=1", "link=Add Campaign"); if ($this->isTextPresent('No campaigns found.')) { - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). - $this->open($this->sboxPath . "civicrm/participant/add?reset=1&action=add&context=standalone"); - $this->waitForElementPresent("_qf_Participant_upload-bottom"); + + $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom"); $this->assertTrue($this->isTextPresent('There are currently no active Campaigns.')); } + $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); - // Go directly to the URL of the screen that you will be testing - $this->open($this->sboxPath . "civicrm/campaign/add?reset=1"); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Campaign_upload-bottom"); - - // Let's start filling the form with values. $campaignTitle = "Campaign $title"; $this->type("title", $campaignTitle); @@ -153,8 +123,7 @@ class WebTest_Campaign_OfflineEventRegistrationTest extends CiviSeleniumTestCase $this->open($this->sboxPath . "civicrm/event/manage&reset=1"); $eventId = $this->registerUrl(); - $this->open($this->sboxPath . "civicrm/event/manage/settings?reset=1&action=update&id=$eventId"); - $this->waitForElementPresent("_qf_EventInfo_cancel-bottom"); + $this->openCiviPage('event/manage/settings', "reset=1&action=update&id=$eventId", "_qf_EventInfo_cancel-bottom"); // select campaign $this->click("campaign_id"); @@ -169,14 +138,8 @@ class WebTest_Campaign_OfflineEventRegistrationTest extends CiviSeleniumTestCase $contactName = "Anderson, $firstName"; $displayName = "$firstName Anderson"; - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). - $this->open($this->sboxPath . "civicrm/participant/add?reset=1&action=add&context=standalone"); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Participant_upload-bottom"); + $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom"); - // Let's start filling the form with values. // Type contact last name in contact auto-complete, wait for dropdown and click first result $this->webtestFillAutocomplete($firstName); @@ -234,8 +197,7 @@ class WebTest_Campaign_OfflineEventRegistrationTest extends CiviSeleniumTestCase // verify participant record $this->verifyText("xpath=id('ParticipantView')/div[2]/table[1]/tbody/tr[3]/td[2]", preg_quote($campaignTitle)); - $this->open($this->sboxPath . 'civicrm/admin/setting/component?reset=1'); - $this->waitForElementPresent("_qf_Component_next-bottom"); + $this->openCiviPage("admin/setting/component", "reset=1", "_qf_Component_next-bottom"); $this->addSelection("enableComponents-t", "label=CiviCampaign"); $this->click("//option[@value='CiviCampaign']"); $this->click("remove"); @@ -243,8 +205,7 @@ class WebTest_Campaign_OfflineEventRegistrationTest extends CiviSeleniumTestCase $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertTrue($this->isTextPresent("Changes Saved.")); - $this->open($this->sboxPath . 'civicrm/event/search?reset=1'); - $this->waitForElementPresent("_qf_Search_refresh"); + $this->openCiviPage("event/search", "reset=1", "_qf_Search_refresh"); $this->type('sort_name', $firstName); $this->click("_qf_Search_refresh"); diff --git a/tests/phpunit/WebTest/Campaign/OnlineContributionTest.php b/tests/phpunit/WebTest/Campaign/OnlineContributionTest.php index 9d338b4502..181925df00 100644 --- a/tests/phpunit/WebTest/Campaign/OnlineContributionTest.php +++ b/tests/phpunit/WebTest/Campaign/OnlineContributionTest.php @@ -33,17 +33,7 @@ class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase { } function testCreateCampaign() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(); + $this->webtestLogin('admin'); // Create new group $title = substr(sha1(rand()), 0, 7); @@ -80,7 +70,7 @@ class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase { // Enable CiviCampaign module if necessary $this->enableComponents(array('CiviCampaign')); - // add the required Drupal permission + // add the required permission $permissions = array( 'edit-2-administer-civicampaign', 'edit-1-make-online-contributions', @@ -88,10 +78,10 @@ class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase { ); $this->changePermissions($permissions); - // Go directly to the URL of the screen that you will be testing + // Log in as normal user + $this->webtestLogin(); $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); - // Let's start filling the form with values. $campaignTitle = "Campaign $title"; $this->type("title", $campaignTitle); @@ -254,7 +244,7 @@ class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase { $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); //logout - $this->openCiviPage("logout", "reset=1", NULL); + $this->webtestLogout(); //Open Live Contribution Page $this->openCiviPage($registerUrl['url'], $registerUrl['args'], NULL); @@ -297,7 +287,6 @@ class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check contribution - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -324,8 +313,8 @@ class WebTest_Campaign_OnlineContributionTest extends CiviSeleniumTestCase { $this->type('title', $contributionPageTitle); $this->click("_qf_SearchContribution_refresh"); $this->waitForPageToLoad('50000'); - $id = $this->getAttribute("//div[@id='configure_contribution_page']//table/tbody/tr/td/strong[text()='$contributionPageTitle']/../../td[5]/div/span/ul/li/a[text()='Title and Settings']@href"); - $id = explode('id=', $id); + $id = $this->getAttribute("//div[@id='configure_contribution_page']//table/tbody/tr/td/strong[text()='$contributionPageTitle']/../../td[5]/div/span/ul/li/a[text()='Title and Settings']@href"); + $id = explode('id=', $id); $registerUrl = array('url' => 'contribute/transact', 'args' => "reset=1&id=$id[1]"); return $registerUrl; } diff --git a/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php b/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php index 756ec8ff9c..ca54af6e16 100644 --- a/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php +++ b/tests/phpunit/WebTest/Campaign/OnlineEventRegistrationTest.php @@ -33,17 +33,7 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase } function testCreateCampaign() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(); + $this->webtestLogin('admin'); // Create new group $title = substr(sha1(rand()), 0, 7); @@ -80,14 +70,15 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase // Enable CiviCampaign module if necessary $this->enableComponents(array('CiviCampaign')); - // add the required Drupal permission + // add the required permission $permissions = array('edit-2-administer-civicampaign', 'edit-1-register-for-events'); $this->changePermissions($permissions); - // Go directly to the URL of the screen that you will be testing + // Log in as normal user + $this->webtestLogin(); + $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); - // Let's start filling the form with values. $campaignTitle = "Campaign $title"; $this->type("title", $campaignTitle); @@ -127,7 +118,6 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $paymentProcessorId = $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->openCiviPage("event/add", "reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -157,11 +147,8 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase } function _testAddEventInfo($id, $eventTitle, $eventDescription) { - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - // Let's start filling the form with values. $this->select("event_type_id", "value=1"); // select campaign @@ -286,7 +273,7 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase function _testOnlineRegistration($campaignTitle, $registerUrl, $numberRegistrations = 1, $anonymous = TRUE) { if ($anonymous) { - $this->openCiviPage("logout", "reset=1", NULL); + $this->webtestLogout(); } $this->open($registerUrl); @@ -329,7 +316,6 @@ class WebTest_Campaign_OnlineEventRegistrationTest extends CiviSeleniumTestCase $thankStrings = array("Thank You for Registering", "Event Total", "Transaction Date"); $this->assertStringsPresent($thankStrings); - $this->open($this->sboxPath); $this->webtestLogin(); $this->openCiviPage('event/search', 'reset=1', '_qf_Search_refresh'); diff --git a/tests/phpunit/WebTest/Campaign/PetitionUsageScenarioTest.php b/tests/phpunit/WebTest/Campaign/PetitionUsageScenarioTest.php index 3179967d0e..9fddda7bf8 100644 --- a/tests/phpunit/WebTest/Campaign/PetitionUsageScenarioTest.php +++ b/tests/phpunit/WebTest/Campaign/PetitionUsageScenarioTest.php @@ -37,7 +37,7 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase { } function testPetitionUsageScenario() { - $this->webtestLogin(); + $this->webtestLogin('admin'); // Enable CiviCampaign module if necessary $this->enableComponents("CiviCampaign"); @@ -63,16 +63,13 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase { ); $this->changePermissions($permissions); - /////////////// Create Campaign /////////////////////////////// + // Log in as normal user + $this->webtestLogin(); - // Go directly to the URL of the screen that you will be add campaign - $this->open($this->sboxPath . "civicrm/campaign/add?reset=1"); + /////////////// Create Campaign /////////////////////////////// - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Campaign_upload-bottom"); + $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); - // Let's start filling the form with values. $title = substr(sha1(rand()), 0, 7); $this->type("title", "$title Campaign"); @@ -101,7 +98,6 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase { ////////////// Create petition using New Individual profile ////////////////////// - // Go directly to the URL of the screen that you will be add petition $this->open($this->sboxPath . "civicrm/petition/add?reset=1"); // button at the end of this page to show up, to make sure it's fully loaded. @@ -140,8 +136,7 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase { ////////////// Retrieve Sign Petition Url ///////////////////////// // logout and sign as anonymous. - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForElementPresent("edit-submit"); + $this->webtestLogout(); // go to the link that you will be sign as anonymous $this->open($url); @@ -165,12 +160,9 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent("Thank You")); // login - $this->open($this->sboxPath); $this->webtestLogin(); - $this->open($this->sboxPath . "civicrm/campaign?reset=1&subPage=petition"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("link=Add Petition"); + $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition"); // check for unconfirmed petition signature $this->waitForElementPresent("petitions"); @@ -196,8 +188,6 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase { } // ONCE MORE, NO EMAIL VERIFICATION AND CUSTOM THANK-YOU - - // Go directly to the URL of the screen that you will be add petition $this->open($this->sboxPath . "civicrm/petition/add?reset=1"); // button at the end of this page to show up, to make sure it's fully loaded. @@ -241,8 +231,7 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase { $url = $this->getAttribute("xpath=//div[@id='petitions_wrapper']/table[@id='petitions']/tbody/tr/td[10]/span[2][text()='more']/ul/li/a[text()='Sign']@href"); // logout and sign as anonymous. - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForElementPresent("edit-submit"); + $this->webtestLogout(); // go to the link that you will be sign as anonymous $this->open($url); @@ -269,12 +258,9 @@ class WebTest_Campaign_PetitionUsageScenarioTest extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent("Thank you for your kind contribution to support $title")); // login - $this->open($this->sboxPath); $this->webtestLogin(); - $this->open($this->sboxPath . "civicrm/campaign?reset=1&subPage=petition"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("link=Add Petition"); + $this->openCiviPage("campaign", "reset=1&subPage=petition", "link=Add Petition"); // check for confirmed petition signature $this->waitForElementPresent("petitions"); diff --git a/tests/phpunit/WebTest/Campaign/PledgeTest.php b/tests/phpunit/WebTest/Campaign/PledgeTest.php index 0c4cc3e604..d02719dca7 100644 --- a/tests/phpunit/WebTest/Campaign/PledgeTest.php +++ b/tests/phpunit/WebTest/Campaign/PledgeTest.php @@ -33,13 +33,8 @@ class WebTest_Campaign_PledgeTest extends CiviSeleniumTestCase { } function testCreateCampaign() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in as admin first to verify permissions for CiviGrant - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); // Enable CiviCampaign module and CiviPledge module if necessary $this->enableComponents(array("CiviCampaign", "CiviPledge")); @@ -51,11 +46,7 @@ class WebTest_Campaign_PledgeTest extends CiviSeleniumTestCase { ); $this->changePermissions($permissions); - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - // Log in as demo user - $this->open($this->sboxPath); $this->webtestLogin(); // Create new group @@ -90,14 +81,8 @@ class WebTest_Campaign_PledgeTest extends CiviSeleniumTestCase { $this->click("_qf_GroupContact_next"); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to the URL of the screen that you will be testing - $this->open($this->sboxPath . "civicrm/campaign/add?reset=1"); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Campaign_upload-bottom"); + $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); - // Let's start filling the form with values. $campaignTitle = "Campaign $title"; $this->type("title", $campaignTitle); @@ -133,9 +118,9 @@ class WebTest_Campaign_PledgeTest extends CiviSeleniumTestCase { function pledgeAddTest($campaignTitle, $id) { // create unique name - $name = substr(sha1(rand()), 0, 7); + $name = substr(sha1(rand()), 0, 7); $firstName = 'Adam' . $name; - $lastName = 'Jones' . $name; + $lastName = 'Jones' . $name; // create new contact $this->webtestAddContact($firstName, $lastName, $firstName . "@example.com"); @@ -157,7 +142,6 @@ class WebTest_Campaign_PledgeTest extends CiviSeleniumTestCase { // check contact name on pledge form $this->assertTrue($this->isTextPresent("$firstName $lastName")); - // Let's start filling the form with values. $this->type("amount", "100"); $this->type("installments", "10"); $this->select("frequency_unit", "value=week"); diff --git a/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php b/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php index d2b229a4bc..526ea88b69 100644 --- a/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php +++ b/tests/phpunit/WebTest/Campaign/SurveyUsageScenarioTest.php @@ -33,7 +33,7 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { } function testSurveyUsageScenario() { - $this->webtestLogin(); + $this->webtestLogin('admin'); // Create new group $title = substr(sha1(rand()), 0, 7); @@ -69,13 +69,14 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { // Enable CiviCampaign module if necessary $this->enableComponents(array('CiviCampaign')); - // add the required Drupal permission + // add the required permission $this->changePermissions(array('edit-2-administer-civicampaign')); - // Go directly to the URL of the screen that you will be testing + // Log in as normal user + $this->webtestLogin(); + $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); - // Let's start filling the form with values. $this->type("title", "Campaign $title"); // select the campaign type @@ -308,6 +309,14 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { } function testSurveyReportTest() { + $this->webtestLogin('admin'); + + // Enable CiviCampaign module if necessary + $this->enableComponents(array('CiviCampaign')); + + // add the required permission + $this->changePermissions('edit-2-administer-civicampaign'); + $this->webtestLogin(); // Create new group @@ -420,13 +429,6 @@ class WebTest_Campaign_SurveyUsageScenarioTest extends CiviSeleniumTestCase { $this->click('_qf_Field_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Enable CiviCampaign module if necessary - $this->enableComponents(array('CiviCampaign')); - - // add the required Drupal permission - $permissions = array('edit-2-administer-civicampaign'); - $this->changePermissions($permissions); - // Create a survey $this->openCiviPage("survey/add", "reset=1", "_qf_Main_upload-bottom"); diff --git a/tests/phpunit/WebTest/Case/ActivityToCaseTest.php b/tests/phpunit/WebTest/Case/ActivityToCaseTest.php index 512a2a2b9d..9233a8acce 100644 --- a/tests/phpunit/WebTest/Case/ActivityToCaseTest.php +++ b/tests/phpunit/WebTest/Case/ActivityToCaseTest.php @@ -33,10 +33,8 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { } function testAddActivityToCase() { - $this->open($this->sboxPath); - // Log in as admin first to verify permissions for CiviCase - $this->webtestLogin(); + $this->webtestLogin('true'); // Enable CiviCase module if necessary $this->enableComponents("CiviCase"); @@ -45,7 +43,9 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); $this->changePermissions($permission); - // Go directly to the URL of the screen that you will be testing (New Case-standalone). + // Log in as normal user + $this->webtestLogin(); + $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); // Adding contact with randomized first name (so we can then select that contact when creating case) @@ -98,7 +98,6 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { $firstName2 = substr(sha1(rand()), 0, 7); $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name"); - // Go directly to the URL of the screen that you will be testing (Activity Tab). $this->click("css=li#tab_activity a"); // waiting for the activity dropdown to show up @@ -111,7 +110,6 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_Activity_upload-bottom"); - // Let's start filling the form with values. // ...and verifying if the page contains properly formatted display name for chosen contact. $this->assertElementContainsText('css=tr.crm-activity-form-block-target_contact_id td ul li.token-input-token-facebook', 'Anderson, ' . $firstName2, "Contact not found in line " . __LINE__); @@ -233,7 +231,7 @@ class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { } function _addCustomData($customGroupTitle) { - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->openCiviPage('admin/custom/group', 'reset=1'); //add new custom data diff --git a/tests/phpunit/WebTest/Case/AddCaseTest.php b/tests/phpunit/WebTest/Case/AddCaseTest.php index eeb08487e8..e984c7651c 100644 --- a/tests/phpunit/WebTest/Case/AddCaseTest.php +++ b/tests/phpunit/WebTest/Case/AddCaseTest.php @@ -34,7 +34,7 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { function testStandaloneCaseAdd() { // Log in as admin first to verify permissions for CiviCase - $this->webtestLogin(); + $this->webtestLogin('admin'); // Enable CiviCase module if necessary $this->enableComponents("CiviCase"); @@ -43,6 +43,9 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); $this->changePermissions($permission); + // Log in as normal user + $this->webtestLogin(); + // Go to reserved New Individual Profile to set value for logged in user's contact name (we'll need that later) $this->openCiviPage('profile/edit', 'reset=1&gid=4', NULL); $testUserFirstName = "Testuserfirst"; @@ -57,7 +60,6 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { // Is status message correct? $this->assertElementContainsText('crm-container', "Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!"); - // Go directly to the URL of the screen that you will be testing (New Case-standalone). $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); // Try submitting the form without creating or selecting a contact (test for CRM-7971) @@ -78,10 +80,10 @@ class WebTest_Case_AddCaseTest extends CiviSeleniumTestCase { // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. $caseTypeLabel = "Adult Day Care Referral"; // activity types we expect for this case type - $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation"); - $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client"); + $activityTypes = array("ADC referral", "Follow up", "Medical evaluation", "Mental health evaluation"); + $caseRoles = array("Senior Services Coordinator", "Health Services Coordinator", "Benefits Specialist", "Client"); $caseStatusLabel = "Ongoing"; - $subject = "Safe daytime setting - senior female"; + $subject = "Safe daytime setting - senior female"; $this->select("medium_id", "value=1"); $location = "Main offices"; $this->type("activity_location", $location); diff --git a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php index 6ab4aef049..0d2965a440 100644 --- a/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php +++ b/tests/phpunit/WebTest/Case/CaseCustomFieldsTest.php @@ -33,7 +33,7 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { } function testAddCase() { - $this->webtestLogin(); + $this->webtestLogin('admin'); // Enable CiviCase module if necessary $this->enableComponents("CiviCase"); @@ -64,6 +64,9 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); $this->changePermissions($permission); + // Log in as normal user + $this->webtestLogin(); + // Go to reserved New Individual Profile to set value for logged in user's contact name (we'll need that later) $this->openCiviPage('profile/edit', 'reset=1&gid=4', '_qf_Edit_next'); $testUserFirstName = "Testuserfirst"; @@ -74,7 +77,6 @@ class WebTest_Case_CaseCustomFieldsTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("profilewrap4"); - // Go directly to the URL of the screen that you will be testing (New Case-standalone). $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); // Try submitting the form without creating or selecting a contact (test for CRM-7971) diff --git a/tests/phpunit/WebTest/Case/CaseDashboardTest.php b/tests/phpunit/WebTest/Case/CaseDashboardTest.php index bbd5b10645..7b28b73e04 100644 --- a/tests/phpunit/WebTest/Case/CaseDashboardTest.php +++ b/tests/phpunit/WebTest/Case/CaseDashboardTest.php @@ -33,11 +33,8 @@ class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase { } function testAllOrMyCases() { - - $this->open($this->sboxPath); - // Log in as admin first to verify permissions for CiviCase - $this->webtestLogin(); + $this->webtestLogin('true'); // Enable CiviCase module if necessary $this->enableComponents("CiviCase"); @@ -46,8 +43,10 @@ class WebTest_Case_CaseDashboardTest extends CiviSeleniumTestCase { $permission = array('edit-2-access-all-cases-and-activities', 'edit-2-access-my-cases-and-activities', 'edit-2-administer-civicase', 'edit-2-delete-in-civicase'); $this->changePermissions($permission); - // Go directly to the URL of the screen that you will be testing (Dashboard). - $this->openCiviPage('case', 'reset=1', 'css=a.button'); + // Log in as normal user + $this->webtestLogin(); + + $this->openCiviPage('case', 'reset=1'); // Should default to My Cases $this->assertTrue($this->isChecked("name=allupcoming value=0"), 'Case dashboard should default to My Cases.'); diff --git a/tests/phpunit/WebTest/Contact/AddCmsUserTest.php b/tests/phpunit/WebTest/Contact/AddCmsUserTest.php index 4af9a2a71b..25d080a6f0 100644 --- a/tests/phpunit/WebTest/Contact/AddCmsUserTest.php +++ b/tests/phpunit/WebTest/Contact/AddCmsUserTest.php @@ -33,14 +33,11 @@ class WebTest_Contact_AddCmsUserTest extends CiviSeleniumTestCase { } function testAuthenticAddUser() { - $this->open($this->sboxPath); - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); - // Go directly to the URL of the screen that will Create User Authentically. $this->open($this->sboxPath . "admin/people/create"); - $this->waitForElementPresent("edit-submit"); $name = "TestUserAuthenticated" . substr(sha1(rand()), 0, 4); @@ -71,7 +68,7 @@ class WebTest_Contact_AddCmsUserTest extends CiviSeleniumTestCase { function testAnonymousAddUser() { // Make sure Drupal account settings allow visitors to register for account w/o admin approval // login as admin - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); $this->open($this->sboxPath . "admin/config/people/accounts"); $this->waitForElementPresent("edit-submit"); @@ -80,9 +77,8 @@ class WebTest_Contact_AddCmsUserTest extends CiviSeleniumTestCase { $this->click('edit-submit'); $this->waitForPageToLoad($this->getTimeoutMsec()); // logout - $this->openCiviPage('logout', 'reset=1', NULL); + $this->webtestLogout(); - // Go directly to the URL of the screen that will Create User Anonymously. $this->open($this->sboxPath . "user/register"); $this->waitForElementPresent("edit-submit"); @@ -108,7 +104,7 @@ class WebTest_Contact_AddCmsUserTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // In case the site is set up to login immediately upon registration - $this->open($this->sboxPath . "user/logout"); + $this->webtestLogout(); $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Contact/AddContactsToEventAdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/AddContactsToEventAdvancedSearchTest.php index c564b0601c..12639f6be6 100644 --- a/tests/phpunit/WebTest/Contact/AddContactsToEventAdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/AddContactsToEventAdvancedSearchTest.php @@ -33,16 +33,6 @@ class WebTest_Contact_AddContactsToEventAdvancedSearchTest extends CiviSeleniumT } function testAddContactsToEventAdvanceSearch() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Contact/AddTest.php b/tests/phpunit/WebTest/Contact/AddTest.php index 7828ecc157..f37cc787d5 100644 --- a/tests/phpunit/WebTest/Contact/AddTest.php +++ b/tests/phpunit/WebTest/Contact/AddTest.php @@ -35,7 +35,6 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase { function testIndividualAdd() { $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->WebtestAddGroup(); // go to display preferences to enable Open ID field @@ -177,7 +176,6 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase { $this->click("_qf_Display_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to the URL of the screen that you will be testing (New Household). $this->openCiviPage('contact/add', "reset=1&ct=Household"); //contact details section @@ -283,7 +281,7 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase { $this->check("xpath=//ul[@id='contactEditBlocks']//li/span[2]/label[text()='Open ID']/../input"); $this->click("_qf_Display_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to the URL of the screen that you will be testing (New Organization). + $this->openCiviPage('contact/add', 'reset=1&ct=Organization'); //contact details section @@ -377,7 +375,6 @@ class WebTest_Contact_AddTest extends CiviSeleniumTestCase { function testIndividualAddWithSharedAddress() { $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->openCiviPage('contact/add', "reset=1&ct=Individual"); //contact details section diff --git a/tests/phpunit/WebTest/Contact/AddViaProfileTest.php b/tests/phpunit/WebTest/Contact/AddViaProfileTest.php index a50c53985d..1f633efedd 100644 --- a/tests/phpunit/WebTest/Contact/AddViaProfileTest.php +++ b/tests/phpunit/WebTest/Contact/AddViaProfileTest.php @@ -33,19 +33,8 @@ class WebTest_Contact_AddViaProfileTest extends CiviSeleniumTestCase { } function testAddViaCreateProfile() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (Create Profile). $this->openCiviPage('profile/create', 'reset=1&gid=1', '_qf_Edit_cancel'); $firstName = 'Jo' . substr(sha1(rand()), 0, 4); diff --git a/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php b/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php index 64aa4b6a42..092afb3a3f 100644 --- a/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php +++ b/tests/phpunit/WebTest/Contact/AdvanceSearchPaneTest.php @@ -36,16 +36,6 @@ class WebTest_Contact_AdvanceSearchPaneTest extends CiviSeleniumTestCase { * Function to test individual pane seperatly. */ function testIndividualPanes() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get all default advance search panes. @@ -72,16 +62,6 @@ class WebTest_Contact_AdvanceSearchPaneTest extends CiviSeleniumTestCase { * Function to test by selecting all panes at a time. */ function testAllPanes() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get all default advance search panes. diff --git a/tests/phpunit/WebTest/Contact/AdvanceSearchPrivacyOptionsTest.php b/tests/phpunit/WebTest/Contact/AdvanceSearchPrivacyOptionsTest.php index d54aeaf513..3aad14ce40 100644 --- a/tests/phpunit/WebTest/Contact/AdvanceSearchPrivacyOptionsTest.php +++ b/tests/phpunit/WebTest/Contact/AdvanceSearchPrivacyOptionsTest.php @@ -33,16 +33,6 @@ class WebTest_Contact_AdvanceSearchPrivacyOptionsTest extends CiviSeleniumTestCa } function testSearchForPrivacyOptions() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $privacyOptions = array( diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php index bb9f64bb01..369cdf97c2 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchTest.php @@ -33,17 +33,6 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { } function testAdvanceSearch() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -143,7 +132,6 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { //-------------- advance search -------------- - // Go directly to the URL of the screen that you will be testing (Advance Search). $this->openCiviPage('contact/search/advanced', 'reset=1'); //also create a dummy name to test false @@ -203,7 +191,6 @@ class WebTest_Contact_AdvancedSearchTest extends CiviSeleniumTestCase { * Check for CRM-9873 */ function testActivitySearchByTypeTest() { - $this->open($this->sboxPath); $this->webtestLogin(); $this->openCiviPage('contact/search/advanced', 'reset=1'); $this->click("activity"); diff --git a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php index 95e1e581fd..cb6d589012 100644 --- a/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php +++ b/tests/phpunit/WebTest/Contact/AdvancedSearchedRelatedContactTest.php @@ -33,11 +33,6 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes } function testSearchRelatedContact() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -45,7 +40,6 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $paymentProcessorId = $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->openCiviPage('event/add', 'reset=1&action=add'); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -146,11 +140,8 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes } function _testAddEventInfo($eventTitle, $eventDescription) { - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - // Let's start filling the form with values. $this->select("event_type_id", "value=1"); // Attendee role s/b selected now. @@ -294,16 +285,6 @@ class WebTest_Contact_AdvancedSearchedRelatedContactTest extends CiviSeleniumTes } function testAdvanceSearchForLog() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php b/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php index 13be0a19dc..0068db6bc0 100644 --- a/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php +++ b/tests/phpunit/WebTest/Contact/ContactReferenceFieldTest.php @@ -33,16 +33,6 @@ class WebTest_Contact_ContactReferenceFieldTest extends CiviSeleniumTestCase { } function testContactReferenceField() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); @@ -88,7 +78,7 @@ class WebTest_Contact_ContactReferenceFieldTest extends CiviSeleniumTestCase { /* create custom group and fields */ // Add Custom group // - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->openCiviPage('admin/custom/group', 'action=add&reset=1'); //fill custom group title diff --git a/tests/phpunit/WebTest/Contact/ContactTagTest.php b/tests/phpunit/WebTest/Contact/ContactTagTest.php index 9d83b3cddb..5f0edfbb7d 100644 --- a/tests/phpunit/WebTest/Contact/ContactTagTest.php +++ b/tests/phpunit/WebTest/Contact/ContactTagTest.php @@ -33,24 +33,9 @@ class WebTest_Contact_ContactTagTest extends CiviSeleniumTestCase { } function testTagAContact() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Tag). - $this->open($this->sboxPath . "civicrm/admin/tag?action=add&reset=1"); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Tag_next"); + $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next"); // take a tag name $tagName = 'tag_' . substr(sha1(rand()), 0, 7); @@ -92,19 +77,8 @@ class WebTest_Contact_ContactTagTest extends CiviSeleniumTestCase { } function testTagSetContact() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Tag). $this->open($this->sboxPath . "civicrm/admin/tag?action=add&reset=1&tagset=1"); // take a tagset name diff --git a/tests/phpunit/WebTest/Contact/CreateCmsUserFromContactTest.php b/tests/phpunit/WebTest/Contact/CreateCmsUserFromContactTest.php index 6006d9c83b..418be7e74b 100644 --- a/tests/phpunit/WebTest/Contact/CreateCmsUserFromContactTest.php +++ b/tests/phpunit/WebTest/Contact/CreateCmsUserFromContactTest.php @@ -41,15 +41,14 @@ class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase //Test that option to create a cms user is present on a contact who does not //have a cms account already( in this case, a new contact ) function testCreateContactLinkPresent() { - $this->open($this->sboxPath); //login - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); //create a New Contact $firstName = substr(sha1(rand()), 0, 7) . "John"; - $lastName = substr(sha1(rand()), 0, 7) . "Smith"; - $email = $this->webtestAddContact($firstName, $lastName, TRUE); + $lastName = substr(sha1(rand()), 0, 7) . "Smith"; + $email = $this->webtestAddContact($firstName, $lastName, TRUE); //Assert that the user actually does have a CMS Id displayed $this->assertTrue(!$this->isTextPresent("User ID")); @@ -61,10 +60,9 @@ class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase //Test that the action link is missing for users who already have a contact //record. The contact record for drupal user 1 is used function testCreateContactLinkMissing() { - $this->open($this->sboxPath); //login - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); // go to My Account page $this->open($this->sboxPath . "user"); @@ -83,8 +81,7 @@ class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase //Test the ajax "check username availibity" link when adding cms user function testCheckUsernameAvailability() { - $this->open($this->sboxPath); - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); $email = $this->_createUserAndGotoForm(); $password = "abc123"; @@ -108,10 +105,9 @@ class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase //Test form submission when the username is taken function testTakenUsernameSubmission() { - $this->open($this->sboxPath); //login - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); //create a New Contact list($cid, $firstName, $lastName, $email) = $this->_createUserAndGotoForm(); @@ -134,10 +130,9 @@ class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase //Test form sumbission when user passwords dont match function testMismatchPasswordSubmission() { - $this->open($this->sboxPath); //login - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); //create a New Contact list($cid, $firstName, $lastName, $email) = $this->_createUserAndGotoForm(); @@ -159,10 +154,9 @@ class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase } function testMissingDataSubmission() { - $this->open($this->sboxPath); //login - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); //create a New Contact list($cid, $firstName, $lastName, $email) = $this->_createUserAndGotoForm(); @@ -191,10 +185,9 @@ class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase //Test a valid (username unique and passwords match) submission function testValidSubmission() { - $this->open($this->sboxPath); //login - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); //create a New Contact list($cid, $firstName, $lastName, $email) = $this->_createUserAndGotoForm(); @@ -225,8 +218,8 @@ class WebTest_Contact_CreateCmsUserFromContactTest extends CiviSeleniumTestCase function _createUserAndGoToForm() { $firstName = substr(sha1(rand()), 0, 7) . "John"; - $lastName = substr(sha1(rand()), 0, 7) . "Smith"; - $email = $this->webtestAddContact($firstName, $lastName, TRUE); + $lastName = substr(sha1(rand()), 0, 7) . "Smith"; + $email = $this->webtestAddContact($firstName, $lastName, TRUE); // Get the contact id of the new contact $contactUrl = $this->parseURL(); diff --git a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php index 64898cba59..b6be9c0534 100644 --- a/tests/phpunit/WebTest/Contact/CustomDataAddTest.php +++ b/tests/phpunit/WebTest/Contact/CustomDataAddTest.php @@ -33,19 +33,8 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { } function testCustomDataAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Custom Group). $this->openCiviPage('admin/custom/group', 'action=add&reset=1'); //fill custom group title @@ -167,15 +156,9 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { } function testCustomDataMoneyAdd() { - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to the URL of the screen that you will be testing (New Custom Group). $this->openCiviPage('admin/custom/group', 'action=add&reset=1'); //fill custom group title @@ -257,13 +240,6 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { // This is the path where our testing install resides. // The rest of URL is defined in CiviSeleniumTestCase base class, in // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); //enable logging @@ -296,7 +272,6 @@ class WebTest_Contact_CustomDataAddTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertElementContainsText('crm-notification-container', "Your custom field '$customField' has been saved."); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->openCiviPage('contact/add', 'reset=1&ct=Individual'); //contact details section diff --git a/tests/phpunit/WebTest/Contact/DeceasedContactsAdvancedSearchTest.php b/tests/phpunit/WebTest/Contact/DeceasedContactsAdvancedSearchTest.php index 5198729f11..ef49d038f0 100644 --- a/tests/phpunit/WebTest/Contact/DeceasedContactsAdvancedSearchTest.php +++ b/tests/phpunit/WebTest/Contact/DeceasedContactsAdvancedSearchTest.php @@ -33,16 +33,6 @@ class WebTest_Contact_DeceasedContactsAdvancedSearchTest extends CiviSeleniumTes } function testDeceasedContactsAdvanceSearch() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Contact/DupeContactTest.php b/tests/phpunit/WebTest/Contact/DupeContactTest.php index 5f45ae0eed..b4d8fd8d40 100644 --- a/tests/phpunit/WebTest/Contact/DupeContactTest.php +++ b/tests/phpunit/WebTest/Contact/DupeContactTest.php @@ -33,19 +33,8 @@ class WebTest_Contact_DupeContactTest extends CiviSeleniumTestCase { } function testDuplicateContactAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of New Individual. $this->openCiviPage('contact/add', 'reset=1&ct=Individual'); $firstName = substr(sha1(rand()), 0, 7); @@ -76,7 +65,6 @@ class WebTest_Contact_DupeContactTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertElementContainsText('crm-notification-container', "Contact Saved"); - // Go directly to the URL of New Individual. $this->openCiviPage('contact/add' , 'reset=1&ct=Individual'); //contact details section diff --git a/tests/phpunit/WebTest/Contact/GroupAddTest.php b/tests/phpunit/WebTest/Contact/GroupAddTest.php index a58361027d..c0ed6e8195 100644 --- a/tests/phpunit/WebTest/Contact/GroupAddTest.php +++ b/tests/phpunit/WebTest/Contact/GroupAddTest.php @@ -97,7 +97,7 @@ class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase { } function testGroupReserved() { - $this->webtestLogin(true); + $this->webtestLogin('admin'); $this->openCiviPage('group/add', 'reset=1', '_qf_Edit_upload-bottom'); @@ -158,13 +158,7 @@ class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase { $this->changePermissions($permissions); // Now logout as admin, login as regular user and verify that Group settings, delete and disable links are not available - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->waitForElementPresent('edit-submit'); - $this->type('edit-name', $user); - $this->type('edit-pass', 'Test12345'); - $this->click('edit-submit'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogin($user, 'Test12345'); $this->openCiviPage('group', 'reset=1'); $this->type('title', $params['name']); @@ -174,16 +168,13 @@ class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase { $this->assertElementNotContainsText("css=td.crm-group-group_links", "Settings"); //login as admin and delete the role - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); $this->open($this->sboxPath . "admin/people/permissions/roles"); $this->_roleDelete($role); } function _testCreateUser($roleid) { - // Go directly to the URL of the screen that will Create User Authentically. $this->open($this->sboxPath . "admin/people/create"); $this->waitForElementPresent("edit-submit"); @@ -225,4 +216,4 @@ class WebTest_Contact_GroupAddTest extends CiviSeleniumTestCase { $this->click("edit-submit"); $this->waitForTextPresent("The role has been deleted."); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php index a9825c7b20..44c3f18534 100644 --- a/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php +++ b/tests/phpunit/WebTest/Contact/InlineFieldsEditTest.php @@ -33,16 +33,6 @@ class WebTest_Contact_InlineFieldsEditTest extends CiviSeleniumTestCase { } function testAddAndEditField() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Add a contact diff --git a/tests/phpunit/WebTest/Contact/MergeContactsTest.php b/tests/phpunit/WebTest/Contact/MergeContactsTest.php index 8f9a10bcfc..3fd0e8a4a4 100644 --- a/tests/phpunit/WebTest/Contact/MergeContactsTest.php +++ b/tests/phpunit/WebTest/Contact/MergeContactsTest.php @@ -33,14 +33,8 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { } function testIndividualAdd() { - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of New Individual. $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -169,8 +163,7 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent("{$fname2} {$lname2}"), "Redirect for Goto Next Pair after merge did not work."); // Ensure that the duplicate contact has been deleted - $this->open($this->sboxPath . 'civicrm/contact/search/advanced?reset=1'); - $this->waitForElementPresent('_qf_Advanced_refresh'); + $this->openCiviPage("contact/search/advanced", "reset=1", '_qf_Advanced_refresh'); $this->type('sort_name', $firstName); $this->check('deleted_contacts'); $this->click('_qf_Advanced_refresh'); @@ -178,8 +171,7 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent('1 Contact'), "Deletion of duplicate contact during merge was not successful. Dupe contact not found when searching trash."); // Search for the main contact - $this->open($this->sboxPath . 'civicrm/contact/search/advanced?reset=1'); - $this->waitForElementPresent('_qf_Advanced_refresh'); + $this->openCiviPage("contact/search/advanced", "reset=1", '_qf_Advanced_refresh'); $this->type('sort_name', $firstName); $this->click('_qf_Advanced_refresh'); $this->waitForElementPresent("xpath=//form[@id='Advanced']/div[3]/div/div[2]/table/tbody/tr"); @@ -229,7 +221,6 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_Activity_upload"); - // Let's start filling the form with values. // ...and verifying if the page contains properly formatted display name for chosen contact. $this->assertTrue($this->isTextPresent("Anderson, " . $withContact), "Contact not found in line " . __LINE__); @@ -289,14 +280,8 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { function testMergeTest() { - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of New Individual. $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -395,7 +380,6 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { $this->assertTrue($this->isElementPresent("xpath=//div[@id='phone-block']/div/div/div[4]/div[2][contains(text(), '9876543120')]")); //Merge with the feature of (add) - // Go directly to the URL of New Individual. $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -488,11 +472,6 @@ class WebTest_Contact_MergeContactsTest extends CiviSeleniumTestCase { } function testBatchMerge(){ - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // add contact1 and its duplicate diff --git a/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php b/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php index 458cbe49ff..4f384aeaaa 100644 --- a/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php +++ b/tests/phpunit/WebTest/Contact/MultipleContactSubTypes.php @@ -33,16 +33,6 @@ class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase { } function testIndividualAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $selection1 = 'Student'; @@ -54,7 +44,6 @@ class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase { list($groupTitleForParent, $customGroupIdForParent) = $this->_addCustomData($selection2); list($groupTitleForStaff, $customGroupIdForStaff) = $this->_addCustomData($selection3); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); //contact details section @@ -281,7 +270,7 @@ class WebTest_Contact_MultipleContactSubTypes extends CiviSeleniumTestCase { } function _addCustomData($contactSubType) { - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->open($this->sboxPath . "civicrm/admin/custom/group?reset=1"); //add new custom data diff --git a/tests/phpunit/WebTest/Contact/PrevNextTest.php b/tests/phpunit/WebTest/Contact/PrevNextTest.php index 2dd2e22367..cd3e0ca7aa 100644 --- a/tests/phpunit/WebTest/Contact/PrevNextTest.php +++ b/tests/phpunit/WebTest/Contact/PrevNextTest.php @@ -33,16 +33,6 @@ class WebTest_Contact_PrevNextTest extends CiviSeleniumTestCase { } function testPrevNext() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php b/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php index 0f52aaaa90..8202288133 100644 --- a/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php +++ b/tests/phpunit/WebTest/Contact/PrivacyOptionSearchTest.php @@ -33,22 +33,11 @@ class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase { } function testPrivacyOptionSearch() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); // Add new group. - $this->open($this->sboxPath . "civicrm/group/add?&reset=1"); - $this->waitForElementPresent("_qf_Edit_upload"); + $this->openCiviPage('group/add', 'reset=1', "_qf_Edit_upload"); $groupName = 'group_' . substr(sha1(rand()), 0, 7); $this->type("title", $groupName); @@ -66,8 +55,7 @@ class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase { // Add Contact1. $fname1 = substr(sha1(rand()), 0, 7); $lname1 = substr(sha1(rand()), 0, 7); - $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Individual'); - $this->waitForElementPresent('_qf_Contact_upload_view-bottom'); + $this->openCiviPage("contact/add", "reset=1&ct=Individual", '_qf_Contact_upload_view-bottom'); $this->type('first_name', $fname1); $this->type('last_name', $lname1); $email1 = $fname1 . '@example.org'; @@ -94,8 +82,7 @@ class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase { // Add Contact2. $fname2 = substr(sha1(rand()), 0, 7); $lname2 = substr(sha1(rand()), 0, 7); - $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Individual'); - $this->waitForElementPresent('_qf_Contact_upload_view-bottom'); + $this->openCiviPage("contact/add", "reset=1&ct=Individual", '_qf_Contact_upload_view-bottom'); $this->type('first_name', $fname2); $this->type('last_name', $lname2); $email2 = $fname2 . '@example.org'; diff --git a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php index ea12a0d2b7..7f91028d61 100644 --- a/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php +++ b/tests/phpunit/WebTest/Contact/ProfileChecksumTest.php @@ -33,17 +33,7 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { } function testProfileChecksum() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); // Profile fields. $fields = array( @@ -116,12 +106,10 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { $this->changePermissions($permission); // Get checksum of the newly created contact. - require_once 'CRM/Contact/BAO/Contact/Utils.php'; $cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactId); - // Logout. - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + // logout. + $this->webtestLogout(); // Go to edit profile page of the created contact. $this->open($this->sboxPath . "civicrm/profile/edit?id={$contactId}&gid={$profileId}&reset=1&cs={$cs}"); @@ -154,8 +142,7 @@ class WebTest_Contact_ProfileChecksumTest extends CiviSeleniumTestCase { } function _testCreateContactProfile($fields, $profileName) { - // Go directly to the URL of the screen that you will be - // testing (Add new profile ). + // Add new profile. $this->open($this->sboxPath . 'civicrm/admin/uf/group?reset=1'); $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); $this->click('newCiviCRMProfile-top'); diff --git a/tests/phpunit/WebTest/Contact/RelationshipAddTest.php b/tests/phpunit/WebTest/Contact/RelationshipAddTest.php index 7200e168cf..02f4e988c9 100644 --- a/tests/phpunit/WebTest/Contact/RelationshipAddTest.php +++ b/tests/phpunit/WebTest/Contact/RelationshipAddTest.php @@ -33,11 +33,6 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { } function testRelationshipAddTest() { - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); //create a relationship type between different contact types @@ -56,8 +51,7 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name"); $sortName = "Anderson, $firstName"; - // Go directly to the URL of the screen that you will be testing (New Household). - $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Household"); + $this->openCiviPage("contact/add", "reset=1&ct=Household"); //fill in Household name $this->click("household_name"); @@ -113,8 +107,7 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent($params['label_b_a'])); //create a New Individual subtype - $this->open($this->sboxPath . "civicrm/admin/options/subtype?action=add&reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('admin/options/subtype', "action=add&reset=1"); $label = "IndividualSubtype" . substr(sha1(rand()), 0, 4); $this->type("label", $label); $this->type("description", "here is individual subtype"); @@ -122,8 +115,7 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //create a new contact of individual subtype - $this->open($this->sboxPath . "civicrm/contact/add?ct=Individual&cst={$label}&reset=1"); - $this->waitForElementPresent('_qf_Contact_upload_view'); + $this->openCiviPage('contact/add', "ct=Individual&cst={$label}&reset=1", '_qf_Contact_upload_view'); $firstName = substr(sha1(rand()), 0, 7); $lastName = 'And' . substr(sha1(rand()), 0, 7); $this->click("first_name"); @@ -137,8 +129,7 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->waitForElementPresent("css=.crm-contact-tabs-list"); //create a New household subtype - $this->open($this->sboxPath . "civicrm/admin/options/subtype?action=add&reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage("admin/options/subtype", "action=add&reset=1"); $label = "HouseholdSubtype" . substr(sha1(rand()), 0, 4); $householdSubtypeName = $label; @@ -150,8 +141,7 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //create a new contact of household subtype - $this->open($this->sboxPath . "civicrm/contact/add?ct=Household&cst={$label}&reset=1"); - $this->waitForElementPresent('_qf_Contact_upload_view'); + $this->openCiviPage('contact/add', "ct=Household&cst={$label}&reset=1", '_qf_Contact_upload_view'); //fill in Household name $householdName = substr(sha1(rand()), 0, 4) . 'home'; @@ -214,7 +204,7 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { ); //create relationship type - $this->open($this->sboxPath . 'civicrm/admin/reltype?reset=1&action=add'); + $this->openCiviPage('admin/reltype', 'reset=1&action=add'); $this->type('label_a_b', $params['label_a_b']); $this->type('label_b_a', $params['label_b_a']); $this->select('contact_types_a', "value={$params['contact_type_a']}"); @@ -248,8 +238,7 @@ class WebTest_Contact_RelationshipAddTest extends CiviSeleniumTestCase { $sortName = "Anderson, $firstName"; //create a new contact of household subtype - $this->open($this->sboxPath . "civicrm/contact/add?ct=Household&cst=" . $householdSubtypeName . "&reset=1"); - $this->waitForElementPresent('_qf_Contact_upload_view'); + $this->openCiviPage('contact/add', "ct=Household&cst={$householdSubtypeName}&reset=1", '_qf_Contact_upload_view'); //fill in Household name $householdName = substr(sha1(rand()), 0, 4) . 'home'; diff --git a/tests/phpunit/WebTest/Contact/SearchBuilderTest.php b/tests/phpunit/WebTest/Contact/SearchBuilderTest.php index 23f2302d50..c9c2bac270 100644 --- a/tests/phpunit/WebTest/Contact/SearchBuilderTest.php +++ b/tests/phpunit/WebTest/Contact/SearchBuilderTest.php @@ -34,11 +34,6 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { function testSearchBuilderOptions() { - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $groupName = $this->WebtestAddGroup(); @@ -113,11 +108,6 @@ class WebTest_Contact_SearchBuilderTest extends CiviSeleniumTestCase { } function testSearchBuilderContacts(){ - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); //Individual diff --git a/tests/phpunit/WebTest/Contact/SearchTest.php b/tests/phpunit/WebTest/Contact/SearchTest.php index 014e7b93cd..159dc3ed44 100644 --- a/tests/phpunit/WebTest/Contact/SearchTest.php +++ b/tests/phpunit/WebTest/Contact/SearchTest.php @@ -43,7 +43,6 @@ class WebTest_Contact_SearchTest extends CiviSeleniumTestCase { $sortName = "Anderson, $firstName"; $displayName = "$firstName Anderson"; - // Go directly to the URL of the screen that you will be testing (Home dashboard). $this->open($this->sboxPath . "civicrm/dashboard?reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -72,7 +71,7 @@ class WebTest_Contact_SearchTest extends CiviSeleniumTestCase { $this->webtestAddContact($firstName, "Adams", "{$firstName}.adams@example.org"); $sortName = "Adams, {$firstName}"; - // Go directly to the URL of the screen that you will be testing (Home dashboard). + $this->open($this->sboxPath . "civicrm/dashboard?reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Contact/SearchbyDateFilterTest.php b/tests/phpunit/WebTest/Contact/SearchbyDateFilterTest.php index 7b4be2e0ab..f84c9a8a2e 100644 --- a/tests/phpunit/WebTest/Contact/SearchbyDateFilterTest.php +++ b/tests/phpunit/WebTest/Contact/SearchbyDateFilterTest.php @@ -36,16 +36,6 @@ class WebTest_Contact_SearchbyDateFilterTest extends CiviSeleniumTestCase { * Function to test individual pane seperatly. */ function testAdvancedSearch() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get all default advance search panes. @@ -73,13 +63,6 @@ class WebTest_Contact_SearchbyDateFilterTest extends CiviSeleniumTestCase { // This is the path where our testing install resides. // The rest of URL is defined in CiviSeleniumTestCase base class, in // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $this->open($this->sboxPath . 'civicrm/contribute/search?reset=1'); diff --git a/tests/phpunit/WebTest/Contact/SignatureTest.php b/tests/phpunit/WebTest/Contact/SignatureTest.php index c2a567c76a..8fea0223cf 100644 --- a/tests/phpunit/WebTest/Contact/SignatureTest.php +++ b/tests/phpunit/WebTest/Contact/SignatureTest.php @@ -147,7 +147,6 @@ class WebTest_Contact_SignatureTest extends CiviSeleniumTestCase { * Helper function to select Editor. */ function _selectEditor($editor) { - // Go directly to the URL of Set Default Editor. $this->openCiviPage('admin/setting/preferences/display', 'reset=1'); // Select your Editor diff --git a/tests/phpunit/WebTest/Contact/TagAddTest.php b/tests/phpunit/WebTest/Contact/TagAddTest.php index e8c928f05f..9306fd4d07 100644 --- a/tests/phpunit/WebTest/Contact/TagAddTest.php +++ b/tests/phpunit/WebTest/Contact/TagAddTest.php @@ -33,24 +33,9 @@ class WebTest_Contact_TagAddTest extends CiviSeleniumTestCase { } function testAddTag() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Tag). - $this->open($this->sboxPath . "civicrm/admin/tag?action=add&reset=1"); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Tag_next"); + $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next"); // take a tag name $tagName = 'tag_' . substr(sha1(rand()), 0, 7); @@ -86,10 +71,8 @@ class WebTest_Contact_TagAddTest extends CiviSeleniumTestCase { } function testAddTagSet() { - $this->open($this->sboxPath); $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Tag). $this->open($this->sboxPath . "civicrm/admin/tag?action=add&reset=1&tagset=1"); // take a tagset name diff --git a/tests/phpunit/WebTest/Contact/TagSetSearchTest.php b/tests/phpunit/WebTest/Contact/TagSetSearchTest.php index 1be7af45a9..8ce1be0502 100644 --- a/tests/phpunit/WebTest/Contact/TagSetSearchTest.php +++ b/tests/phpunit/WebTest/Contact/TagSetSearchTest.php @@ -33,7 +33,6 @@ class WebTest_Contact_TagSetSearchTest extends CiviSeleniumTestCase { } function testTagSetSearch() { - $this->open($this->sboxPath); $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Contact/TaskActionSendMassMailing.php b/tests/phpunit/WebTest/Contact/TaskActionSendMassMailing.php index 4f78e735df..9bb3747044 100644 --- a/tests/phpunit/WebTest/Contact/TaskActionSendMassMailing.php +++ b/tests/phpunit/WebTest/Contact/TaskActionSendMassMailing.php @@ -33,12 +33,9 @@ class WebTest_Contact_TaskActionSendMassMailing extends CiviSeleniumTestCase { } function testSelectedContacts() { - $this->open($this->sboxPath); $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Group). - $this->open($this->sboxPath . "civicrm/group/add&reset=1"); - $this->waitForElementPresent("_qf_Edit_upload"); + $this->openCiviPage('group/add', 'reset=1', "_qf_Edit_upload"); // make group name $groupName = 'group_' . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Contact/TaskActionSendSMS.php b/tests/phpunit/WebTest/Contact/TaskActionSendSMS.php index 16323aa8f9..e68a987e60 100644 --- a/tests/phpunit/WebTest/Contact/TaskActionSendSMS.php +++ b/tests/phpunit/WebTest/Contact/TaskActionSendSMS.php @@ -33,12 +33,10 @@ class WebTest_Contact_TaskActionSendSMS extends CiviSeleniumTestCase { } function testSMSToContacts() { - $this->open($this->sboxPath); $this->webtestLogin(); // ADD a New Group - $this->open($this->sboxPath . "civicrm/group/add?reset=1"); - $this->waitForElementPresent("_qf_Edit_upload"); + $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload"); $smsGroupName = 'group_' . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Contribute/AddBatchesTest.php b/tests/phpunit/WebTest/Contribute/AddBatchesTest.php index 87e9d8fd7d..eb7b511b87 100644 --- a/tests/phpunit/WebTest/Contribute/AddBatchesTest.php +++ b/tests/phpunit/WebTest/Contribute/AddBatchesTest.php @@ -33,16 +33,6 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase { } function testBatchAddContribution() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $itemCount = 5; // create contact @@ -73,16 +63,6 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase { } function testBatchAddMembership() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $itemCount = 5; // create contact @@ -152,8 +132,7 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase { function _checkResult($data, $type) { if ($type == "Contribution") { - $this->open($this->sboxPath . "civicrm/contribute/search?reset=1"); - $this->waitForElementPresent("contribution_date_low"); + $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); $this->type("sort_name", "{$data['first_name']} {$data['last_name']}"); $this->click("_qf_Search_refresh"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -171,8 +150,7 @@ class WebTest_Contribute_AddBatchesTest extends CiviSeleniumTestCase { $this->webtestVerifyTabularData($expected); } elseif ($type == "Membership") { - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForElementPresent("member_join_date_low"); + $this->openCiviPage("member/search", "reset=1", "member_join_date_low"); // select contact $this->type("sort_name", "{$data['first_name']} {$data['last_name']}"); diff --git a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php index 1f453ac80d..54cb3de8e4 100644 --- a/tests/phpunit/WebTest/Contribute/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Contribute/AddPricesetTest.php @@ -41,8 +41,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $financialType = $this->_testAddFinancialType(); $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); - $usedFor = 'Contribution'; - $setHelp = 'Select your conference options.'; + $usedFor = 'Contribution'; + $setHelp = 'Select your conference options.'; $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -67,9 +67,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { } function _testAddSet($setTitle, $usedFor, $setHelp, $financialType = NULL) { - $this->open($this->sboxPath . 'civicrm/admin/price?reset=1&action=add'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent('_qf_Set_next-bottom'); + $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom'); // Enter Priceset fields (Title, Used For ...) $this->type('title', $setTitle); @@ -247,8 +245,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $financialType = $this->_testAddFinancialType(); $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); - $usedFor = 'Contribution'; - $setHelp = 'Select your conference options.'; + $usedFor = 'Contribution'; + $setHelp = 'Select your conference options.'; $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -268,13 +266,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // load the Price Set Preview and check for expected values $this->_testVerifyPriceSet($validateStrings, $sid); - $this->open($this->sboxPath . 'civicrm/contribute/add?reset=1&action=add&context=standalone'); + $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload'); - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent('_qf_Contribution_upload'); - - // Let's start filling the form with values. // create new contact using dialog $firstName = substr(sha1(rand()), 0, 7); @@ -349,8 +342,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { } function _testVerifyRegisterPage($contributionPageTitle) { - $this->open($this->sboxPath . 'civicrm/admin/contribute?reset=1'); - $this->waitForElementPresent('_qf_SearchContribution_refresh'); + $this->openCiviPage("admin/contribute", "reset=1", '_qf_SearchContribution_refresh'); $this->type('title', $contributionPageTitle); $this->click('_qf_SearchContribution_refresh'); $this->waitForPageToLoad('50000'); @@ -361,24 +353,14 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { } function testContributeOnlineWithPriceSet() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); //add financial type of account type expense $financialType = $this->_testAddFinancialType(); $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); - $usedFor = 'Contribution'; - $setHelp = 'Select your conference options.'; + $usedFor = 'Contribution'; + $setHelp = 'Select your conference options.'; $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -431,8 +413,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); //logout - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); //Open Live Contribution Page $this->open($this->sboxPath . $registerUrl); @@ -477,15 +458,12 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check contribution - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); //Find Contribution - $this->open($this->sboxPath . 'civicrm/contribute/search?reset=1'); - - $this->waitForElementPresent('contribution_date_low'); + $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low'); $this->type('sort_name', "$firstName $lastName"); $this->click('_qf_Search_refresh'); @@ -499,9 +477,9 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // View Contribution Record and test for expected values $expected = array( - 'From' => "{$firstName} {$lastName}", - 'Financial Type' => $financialType, - 'Net Amount' => '$ 590.00', + 'From' => "{$firstName} {$lastName}", + 'Financial Type' => $financialType, + 'Net Amount' => '$ 590.00', 'Contribution Status' => 'Completed', ); $this->webtestVerifyTabularData($expected); @@ -515,8 +493,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $financialType= $this->_testAddFinancialType(); $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); - $usedFor = 'Contribution'; - $setHelp = 'Select your conference options.'; + $usedFor = 'Contribution'; + $setHelp = 'Select your conference options.'; $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -568,8 +546,7 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); //logout - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); //Open Live Contribution Page $this->open($this->sboxPath . $registerUrl); @@ -613,15 +590,12 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check contribution - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); //Find Contribution - $this->open($this->sboxPath . 'civicrm/contribute/search?reset=1'); - - $this->waitForElementPresent('contribution_date_low'); + $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low'); $this->type('sort_name', "$firstName $lastName"); $this->click('_qf_Search_refresh'); @@ -635,9 +609,9 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // View Contribution Record and test for expected values $expected = array( - 'From' => "{$firstName} {$lastName}", - 'Financial Type' => $financialType, - 'Net Amount' => '$ 65.00', + 'From' => "{$firstName} {$lastName}", + 'Financial Type' => $financialType, + 'Net Amount' => '$ 65.00', 'Contribution Status' => 'Completed', ); $this->webtestVerifyTabularData($expected); @@ -649,15 +623,15 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { //create a contact and return the contact id $firstNameSoft = "John_".substr(sha1(rand()), 0, 5); - $lastNameSoft = "Doe_".substr(sha1(rand()), 0, 5); + $lastNameSoft = "Doe_".substr(sha1(rand()), 0, 5); $this->webtestAddContact($firstNameSoft, $lastNameSoft); $url = $this->parseURL(); $cid = $url['queryString']['cid']; $this->assertType('numeric', $cid); $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); - $usedFor = 'Contribution'; - $setHelp = 'Select your conference options.'; + $usedFor = 'Contribution'; + $setHelp = 'Select your conference options.'; $financialType = $this->_testAddFinancialType(); $this->_testAddSet($setTitle, $usedFor, $setHelp, $financialType); @@ -679,13 +653,8 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // load the Price Set Preview and check for expected values $this->_testVerifyPriceSet($validateStrings, $sid); - $this->open($this->sboxPath . 'civicrm/contribute/add?reset=1&action=add&context=standalone'); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent('_qf_Contribution_upload'); + $this->openCiviPage("contribute/add", "reset=1&action=add&context=standalone", '_qf_Contribution_upload'); - // Let's start filling the form with values. // create new contact using dialog $firstName = substr(sha1(rand()), 0, 7); @@ -738,13 +707,13 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // View Contribution Record and test for expected values $expected = array( - 'From' => "{$firstName} Contributor", - 'Financial Type' => $financialType, + 'From' => "{$firstName} Contributor", + 'Financial Type' => $financialType, 'Contribution Amount' => 'Contribution Total: $ 590.00', - 'Paid By' => 'Check', - 'Check Number' => '1041', + 'Paid By' => 'Check', + 'Check Number' => '1041', 'Contribution Status' => 'Completed', - 'Soft Credit To' => "$firstNameSoft $lastNameSoft", + 'Soft Credit To' => "$firstNameSoft $lastNameSoft", ); $this->webtestVerifyTabularData($expected); @@ -793,13 +762,13 @@ class WebTest_Contribute_AddPricesetTest extends CiviSeleniumTestCase { // View Contribution Record and test for expected values $expected = array( - 'From' => $fields['values'][$fields['id']]['display_name'], - 'Financial Type' => $fields['values'][$fields['id']]['financial_type'], + 'From' => $fields['values'][$fields['id']]['display_name'], + 'Financial Type' => $fields['values'][$fields['id']]['financial_type'], 'Contribution Amount' => $fields['values'][$fields['id']]['total_amount'], 'Contribution Status' => $fields['values'][$fields['id']]['contribution_status'], - 'Paid By' => $fields['values'][$fields['id']]['contribution_payment_instrument'], - 'Check Number' => $fields['values'][$fields['id']]['contribution_check_number'], - 'Soft Credit To' => $softCreditContact->display_name, + 'Paid By' => $fields['values'][$fields['id']]['contribution_payment_instrument'], + 'Check Number' => $fields['values'][$fields['id']]['contribution_check_number'], + 'Soft Credit To' => $softCreditContact->display_name, ); $this->webtestVerifyTabularData($expected); } diff --git a/tests/phpunit/WebTest/Contribute/ConfirmOptionalTest.php b/tests/phpunit/WebTest/Contribute/ConfirmOptionalTest.php index fb0582a2ee..22bf8e3b88 100644 --- a/tests/phpunit/WebTest/Contribute/ConfirmOptionalTest.php +++ b/tests/phpunit/WebTest/Contribute/ConfirmOptionalTest.php @@ -59,7 +59,6 @@ class WebTest_Contribute_ConfirmOptionalTest extends CiviSeleniumTestCase { protected function _addContributionPage($isConfirmEnabled) { // log in - $this->open($this->sboxPath); $this->webtestLogin(); // create new contribution page @@ -93,9 +92,7 @@ class WebTest_Contribute_ConfirmOptionalTest extends CiviSeleniumTestCase { protected function _fillOutContributionPage() { // load contribution page - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id={$this->pageId}"); - $this->waitForPageToLoad("3000"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id={$this->pageId}", "_qf_Main_upload-bottom"); // fill out info $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", "30"); diff --git a/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php b/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php index 65dd0895c0..e8d096ed15 100644 --- a/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Contribute/ContactContextAddTest.php @@ -32,12 +32,7 @@ class WebTest_Contribute_ContactContextAddTest extends CiviSeleniumTestCase { parent::setUp(); } - function testContactContextAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - + function testContactContextAdd() { // Log in using webtestLogin() method $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php b/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php index bd3136a142..7dca440730 100644 --- a/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php +++ b/tests/phpunit/WebTest/Contribute/ContributionPageAddTest.php @@ -32,8 +32,8 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { $this->webtestLogin(); // a random 7-char string and an even number to make this pass unique - $hash = substr(sha1(rand()), 0, 7); - $rand = 2 * rand(2, 50); + $hash = substr(sha1(rand()), 0, 7); + $rand = 2 * rand(2, 50); $pageTitle = 'Donate Online ' . $hash; // create contribution page with randomized title and default params $pageId = $this->webtestAddContributionPage($hash, $rand, $pageTitle, array("Webtest Dummy" . substr(sha1(rand()), 0, 7) => 'Dummy'), TRUE, TRUE, 'required'); @@ -80,8 +80,8 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { $this->webtestLogin(); // a random 7-char string and an even number to make this pass unique - $hash = substr(sha1(rand()), 0, 7); - $rand = 2 * rand(2, 50); + $hash = substr(sha1(rand()), 0, 7); + $rand = 2 * rand(2, 50); $pageTitle = 'Donate Online ' . $hash; // create contribution page with randomized title, default params and separate payment for Membership and Contribution @@ -130,8 +130,8 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { $this->webtestLogin(); // a random 7-char string and an even number to make this pass unique - $hash = substr(sha1(rand()), 0, 7); - $rand = 2 * rand(2, 50); + $hash = substr(sha1(rand()), 0, 7); + $rand = 2 * rand(2, 50); $pageTitle = 'Donate Online ' . $hash; // create contribution page with randomized title, default params and separate payment for Membership and Contribution @@ -151,8 +151,7 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { //get Url for Live Contribution Page $registerUrl = "civicrm/contribute/transact?reset=1&id=$pageId"; //logout - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); //Open Live Contribution Page $this->open($this->sboxPath . $registerUrl); @@ -174,15 +173,10 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check contribution - $this->open($this->sboxPath); - - // Log in using webtestLogin() method $this->webtestLogin(); //Find Contribution - $this->open($this->sboxPath . 'civicrm/contribute/search?reset=1'); - - $this->waitForElementPresent('contribution_date_low'); + $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low'); $this->type('sort_name', "$firstName $lastName"); $this->select('financial_type_id',"label=Member Dues"); @@ -196,8 +190,8 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); $expected = array( - 'From' => "{$firstName} {$lastName}", - 'Financial Type' => 'Member Dues', + 'From' => "{$firstName} {$lastName}", + 'Financial Type' => 'Member Dues', 'Total Amount' => '$ 50.00', 'Contribution Status' => 'Pending : Pay Later', ); @@ -219,8 +213,8 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent('_qf_ContributionView_cancel-bottom'); $expected = array( - 'From' => "{$firstName} {$lastName}", - 'Financial Type' => 'Donation', + 'From' => "{$firstName} {$lastName}", + 'Financial Type' => 'Donation', 'Contribution Status' => 'Pending : Pay Later', ); $this->webtestVerifyTabularData($expected); @@ -228,8 +222,7 @@ class WebTest_Contribute_ContributionPageAddTest extends CiviSeleniumTestCase { //Find Member - $this->open($this->sboxPath . 'civicrm/member/search?reset=1'); - $this->waitForElementPresent('member_source'); + $this->openCiviPage("member/search", "reset=1", 'member_source'); $this->type('sort_name', "$firstName $lastName"); $this->click('_qf_Search_refresh'); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php index 5fe7847970..fa3df5d4ff 100644 --- a/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OfflineContributionTest.php @@ -44,12 +44,6 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { // The rest of URL is defined in CiviSeleniumTestCase base class, in // class attributes. $this->open( $this->sboxPath ); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Create a contact to be used as soft creditor @@ -209,12 +203,6 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { // The rest of URL is defined in CiviSeleniumTestCase base class, in // class attributes. $this->open( $this->sboxPath ); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); //add authorize .net payment processor @@ -374,4 +362,4 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase { $this->click("_qf_ContributionView_cancel-top"); $this->waitForPageToLoad($this->getTimeoutMsec()); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php b/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php index e6fec2ee62..d86e6439a4 100644 --- a/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OfflineRecurContributionTest.php @@ -33,7 +33,6 @@ class WebTest_Contribute_OfflineRecurContributionTest extends CiviSeleniumTestCa } function testOfflineRecurContribution() { - $this->open($this->sboxPath); $this->webtestLogin(); // We need a payment processor @@ -85,8 +84,7 @@ class WebTest_Contribute_OfflineRecurContributionTest extends CiviSeleniumTestCa $this->waitForPageToLoad($this->getTimeoutMsec()); // Use Find Contributions to make sure test recurring contribution exists - $this->open($this->sboxPath . 'civicrm/contribute/search?reset=1'); - $this->waitForElementPresent('contribution_currency_type'); + $this->openCiviPage("contribute/search", "reset=1", 'contribution_currency_type'); $this->type('sort_name', "$lastName, $firstName"); $this->click('contribution_test'); diff --git a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php index 6c54ef3772..e7a250b64e 100644 --- a/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php +++ b/tests/phpunit/WebTest/Contribute/OnBehalfOfOrganization.php @@ -33,23 +33,12 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { } function testOnBehalfOfOrganization() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // create new individual - $firstName = 'John_' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); - $email = "{$firstName}.{$lastName}@example.com"; + $firstName = 'John_' . substr(sha1(rand()), 0, 7); + $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); + $email = "{$firstName}.{$lastName}@example.com"; $contactParams = array( 'first_name' => $firstName, 'last_name' => $lastName, @@ -114,34 +103,21 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { ); //logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); //$this->_testAnomoyousOganization($pageId, $cid, $pageTitle); - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); $this->_testUserWithOneRelationship($pageId, $cid, $pageTitle); - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); $this->_testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle); } function testOnBehalfOfOrganizationWithMembershipData() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // create new individual $this->open($this->sboxPath . "civicrm/profile/edit?reset=1&gid=4"); - $firstName = 'John_x_' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7); + $firstName = 'John_x_' . substr(sha1(rand()), 0, 7); + $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("_qf_Edit_next"); @@ -151,11 +127,11 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("profilewrap4"); - // Is status message correct? + // Is status message correct? $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!"); //custom data - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->open($this->sboxPath . "civicrm/admin/custom/group?action=add&reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -252,7 +228,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { //Is custom field created $this->assertTrue($this->isTextPresent("Your custom field '$radioFieldLabel' has been saved.")); - + //add the above custom data to the On Behalf of Profile $this->open($this->sboxPath . "civicrm/admin/uf/group?reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -291,11 +267,11 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_Membership_cancel-bottom'); - // fill in Membership Organization and Type + // fill in Membership Organization and Type $this->select('membership_type_id[0]', "value=1"); $this->select('membership_type_id[1]', "value=1"); - // fill in Source + // fill in Source $sourceText = 'On behalf Membership Webtest'; $this->type('source', $sourceText); @@ -303,11 +279,11 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click("css=div#{$customGroupTitle} div.crm-accordion-header"); //$this->waitForElementPresent('_qf_Membership_cancel-bottom111'); - // select newly created processor + // select newly created processor $xpath = "xpath=//label[text() = '{$checkboxOptionLabel1}']/preceding-sibling::input[1]"; $this->assertTrue($this->isTextPresent($checkboxOptionLabel1)); $this->check($xpath); - + $xpath = "xpath=//label[text() = '{$checkboxOptionLabel3}']/preceding-sibling::input[1]"; $this->assertTrue($this->isTextPresent($checkboxOptionLabel3)); $this->check($xpath); @@ -329,21 +305,21 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForElementPresent('relationship_type_id'); $this->click("relationship_type_id"); $this->select("relationship_type_id", "label=Employer of"); - // search organization + // search organization $this->type('contact_1', $firstName); $this->click("contact_1"); $this->waitForElementPresent("css=div.ac_results-inner li"); $this->click("css=div.ac_results-inner li"); $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1')); - // give permission + // give permission $this->click("is_permission_a_b"); $this->click("is_permission_b_a"); - // save relationship + // save relationship $this->click("details-save"); $this->waitForPageToLoad($this->getTimeoutMsec()); - + // We need a payment processor $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $processorType = 'Dummy'; @@ -392,10 +368,10 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $isSeparatePayment, $honoreeSection ); - + //check for formRule //scenario 1 : add membership data in pre / post profile and check for formRule - //add new profile + //add new profile $this->open($this->sboxPath . "civicrm/admin/uf/group?reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -419,31 +395,29 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click('_qf_Field_next_new-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$checkboxFieldLabel}' has been saved to '{$profileTitle}'.")); - - $this->open($this->sboxPath . "civicrm/admin/contribute/custom?reset=1&action=update&id={$pageId}"); - $this->waitForElementPresent('_qf_Custom_next-bottom'); + + $this->openCiviPage("admin/contribute/custom", "reset=1&action=update&id={$pageId}", '_qf_Custom_next-bottom'); $this->select('custom_pre_id', "label={$profileTitle}"); $this->click('_qf_Custom_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); sleep(3); $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page"); - + $this->select('custom_pre_id', "- select -"); $this->select('custom_post_id', "label={$profileTitle}"); $this->click('_qf_Custom_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); sleep(3); $this->assertTrue($this->isTextPresent('You should move the membership related fields in the "On Behalf" profile for this Contribution Page'), "Form rule didn't showed up while incorrectly configuring membership fields profile for 'on behalf of' contribution page"); - - //scenario 2 : disable 'on behalf of', add membership data in pre / post profile + + //scenario 2 : disable 'on behalf of', add membership data in pre / post profile //then try to add 'on behalf of' and check for formRule //disable 'on behalf of' - $this->open($this->sboxPath . "civicrm/admin/contribute/settings?reset=1&action=update&id={$pageId}"); - $this->waitForElementPresent('_qf_Settings_next-bottom'); + $this->openCiviPage("admin/contribute/settings", "reset=1&action=update&id={$pageId}", '_qf_Settings_next-bottom'); $this->uncheck('is_organization'); $this->click('_qf_Settings_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - + //set a membership field profile for this contribution page $this->click('css=li#tab_custom a'); $this->waitForElementPresent('_qf_Custom_next-bottom'); @@ -457,32 +431,20 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->check('is_organization'); $this->click('_qf_Settings_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - sleep(3); + sleep(3); $this->assertTrue($this->isTextPresent("You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page"), "Form rule 'You should move the membership related fields configured in 'Includes Profile (top of page)' to the 'On Behalf' profile for this Contribution Page' didn't showed up"); - + //logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); } function testOnBehalfOfOrganizationWithOrgData() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $this->open($this->sboxPath . "civicrm/profile/edit?reset=1&gid=4"); - $firstName = 'John_x_' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7); + $firstName = 'John_x_' . substr(sha1(rand()), 0, 7); + $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("_qf_Edit_next"); @@ -496,10 +458,10 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { print_r($urlElements); $cid = $urlElements['queryString']['id']; $this->assertType('numeric', $cid); - // Is status message correct? + // Is status message correct? $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!"); - + //add org fields to profile $this->open($this->sboxPath . "civicrm/admin/uf/group?reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -510,7 +472,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click("link=Add Field"); $this->waitForElementPresent('_qf_Field_next-bottom'); - + $this->select('field_name[0]', 'value=Organization'); $this->select('field_name[1]', 'label=Legal Identifier'); $this->click('field_name[1]'); @@ -522,7 +484,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click('field_name[1]'); $this->click('_qf_Field_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - + //create organisation $orgName = "Org WebAccess ". substr(sha1(rand()), 0, 7); @@ -538,18 +500,18 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForElementPresent('relationship_type_id'); $this->click("relationship_type_id"); $this->select("relationship_type_id", "label=Employer of"); - // search organization + // search organization $this->type('contact_1', $firstName); $this->click("contact_1"); $this->waitForElementPresent("css=div.ac_results-inner li"); $this->click("css=div.ac_results-inner li"); $this->assertContains($firstName, $this->getValue('contact_1'), "autocomplete expected $firstName but didn’t find it in " . $this->getValue('contact_1')); - // give permission + // give permission $this->click("is_permission_a_b"); $this->click("is_permission_b_a"); - // save relationship + // save relationship $this->waitForElementPresent("details-save"); $this->click("details-save"); $this->waitForElementPresent("Relationships"); @@ -600,7 +562,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $honoreeSection ); - $this->_testOrganization($pageId, $cid, $pageTitle); + $this->_testOrganization($pageId, $cid, $pageTitle); } @@ -646,8 +608,8 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->type('css=div.other_amount-section input', 60); $firstName = 'Ma' . substr(sha1(rand()), 0, 4); - $lastName = 'An' . substr(sha1(rand()), 0, 7); - $orgName = 'org_11_' . substr(sha1(rand()), 0, 7); + $lastName = 'An' . substr(sha1(rand()), 0, 7); + $orgName = 'org_11_' . substr(sha1(rand()), 0, 7); $this->type("email-5", $firstName . "@example.com"); // enable onbehalforganization block @@ -691,7 +653,6 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check contribution - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -720,19 +681,11 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { } function _testUserWithOneRelationship($pageId, $cid, $pageTitle) { - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogin('admin'); // Create new group $groupName = $this->WebtestAddGroup(); - $this->open($this->sboxPath . "civicrm/group?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("_qf_Search_refresh"); + $this->openCiviPage("group", "reset=1", "_qf_Search_refresh"); $groupId = $this->getText("xpath=//table[@id='crm-group-selector']/tbody//tr/td[text()='{$groupName}']/../td[2]"); $this->open($this->sboxPath . "civicrm/contact/view?reset=1&cid={$cid}"); @@ -763,8 +716,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click("_qf_GroupContact_next"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/admin/custom/group?action=add&reset=1"); - $this->waitForElementPresent("_qf_Group_next-bottom"); + $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom"); // fill in a unique title for the custom group $groupTitle = "Custom Group" . substr(sha1(rand()), 0, 7); @@ -794,18 +746,15 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { // Enable CiviCampaign module if necessary $this->enableComponents("CiviCampaign"); - // add the required Drupal permission + // add the required permission $permission = array('edit-2-administer-civicampaign'); $this->changePermissions($permission); - // Go directly to the URL of the screen that you will be add campaign - $this->open($this->sboxPath . "civicrm/campaign/add?reset=1"); + // Log in as normal user + $this->webtestLogin(); - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Campaign_upload-bottom"); + $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); - // Let's start filling the form with values. $title = 'Campaign ' . substr(sha1(rand()), 0, 7); $this->type("title", $title); @@ -854,8 +803,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent("Your CiviCRM Profile Field '{$fieldTitle}' has been saved to 'On Behalf Of Organization'.")); // Open Page to create Organization - $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Organization"); - $this->waitForElementPresent("_qf_Contact_upload_view-bottom"); + $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom"); $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7); // Type Organization name @@ -987,18 +935,12 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { } function _testUserWithMoreThanOneRelationship($pageId, $cid, $pageTitle) { - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(); + $this->webtestLogin('admin'); $this->waitForPageToLoad($this->getTimeoutMsec()); // Create new group $groupName = $this->WebtestAddGroup(); - $this->open($this->sboxPath . "civicrm/group?reset=1"); - $this->waitForElementPresent('_qf_Search_refresh'); + $this->openCiviPage("group", "reset=1", '_qf_Search_refresh'); $this->click('_qf_Search_refresh'); $this->waitForElementPresent("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]"); $groupId = $this->getText("xpath=//div[@id='group']/div[3]/table/tbody//tr/td[text()='{$groupName}']/../td[2]"); @@ -1031,8 +973,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click("_qf_GroupContact_next"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/admin/custom/group?action=add&reset=1"); - $this->waitForElementPresent("_qf_Group_next-bottom"); + $this->openCiviPage("admin/custom/group", "action=add&reset=1", "_qf_Group_next-bottom"); // fill in a unique title for the c$groupIdustom group $groupTitle = "Members Custom Group" . substr(sha1(rand()), 0, 7); @@ -1063,18 +1004,15 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { // Enable CiviCampaign module if necessary $this->enableComponents("CiviCampaign"); - // add the required Drupal permission + // add the required permission $permission = array('edit-2-administer-civicampaign'); $this->changePermissions($permission); - // Go directly to the URL of the screen that you will be add campaign - $this->open($this->sboxPath . "civicrm/campaign/add?reset=1"); + // Log in as normal user + $this->webtestLogin(); - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Campaign_upload-bottom"); + $this->openCiviPage("campaign/add", "reset=1", "_qf_Campaign_upload-bottom"); - // Let's start filling the form with values. $title = 'Campaign ' . substr(sha1(rand()), 0, 7); $this->type("title", $title); @@ -1126,8 +1064,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { ); // Open Page to create Organization 1 - $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Organization"); - $this->waitForElementPresent("_qf_Contact_upload_view-bottom"); + $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom"); $orgName1 = 'org1_' . substr(sha1(rand()), 0, 7); // Type Organization name @@ -1160,8 +1097,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // create second orzanization - $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Organization"); - $this->waitForElementPresent("_qf_Contact_upload_view-bottom"); + $this->openCiviPage("contact/add", "reset=1&ct=Organization", "_qf_Contact_upload_view-bottom"); $orgName2 = 'org2_' . substr(sha1(rand()), 0, 7); // Type Organization name @@ -1209,7 +1145,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->type('minimum_fee', '50'); - $this->select( 'financial_type_id', 'value=2' ); + $this->select( 'financial_type_id', 'value=2' ); $this->type('duration_interval', 1); $this->select('duration_unit', "label=year"); @@ -1392,23 +1328,12 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { } - function testOnBehalfOfOrganizationWithImage() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(); - + function testOnBehalfOfOrganizationWithImage() { $this->webtestLogin(); + $this->open($this->sboxPath . "civicrm/profile/edit?reset=1&gid=4"); - $firstName = 'John_x_' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7); - + $firstName = 'John_x_' . substr(sha1(rand()), 0, 7); + $lastName = 'Anderson_c_' . substr(sha1(rand()), 0, 7); + $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("_qf_Edit_next"); $this->type("first_name", $firstName); @@ -1416,20 +1341,20 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->click("_qf_Edit_next"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("profilewrap4"); - + $urlElements = $this->parseURL(); $cid = $urlElements['queryString']['id']; $this->assertType('numeric', $cid); - // Is status message correct? + // Is status message correct? $this->assertTextPresent("Thank you. Your information has been saved.", "Save successful status message didn't show up after saving profile to update testUserName!"); $this->open($this->sboxPath . "civicrm/admin/uf/group?reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("link=Reserved Profiles"); - + $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']"); $this->waitForPageToLoad($this->getTimeoutMsec()); - + $this->click("link=Add Field"); $this->waitForElementPresent('_qf_Field_next-bottom'); @@ -1488,12 +1413,12 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $honoreeSection ); - $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle); - + $this->_testOrganizationWithImageUpload($pageId, $cid, $pageTitle); + $this->open($this->sboxPath . "civicrm/admin/uf/group?reset=1"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("link=Reserved Profiles"); - + $this->click("xpath=//div[@id='reserved-profiles']/div/div/table/tbody//tr/td[1][text()='On Behalf Of Organization']/../td[5]/span/a[text()='Fields']"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("xpath=//table[@id='option11']/tbody//tr/td/span[text()='Image Url']/../following-sibling::td[8]/span[2]/ul/li[2]/a"); @@ -1508,8 +1433,8 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=" . $pageId); $firstName = 'Ma' . substr(sha1(rand()), 0, 4); - $lastName = 'An' . substr(sha1(rand()), 0, 7); - $orgName = 'org_11_' . substr(sha1(rand()), 0, 7); + $lastName = 'An' . substr(sha1(rand()), 0, 7); + $orgName = 'org_11_' . substr(sha1(rand()), 0, 7); $this->type("email-5", $firstName . "@example.com"); // onbehalforganization info @@ -1534,7 +1459,7 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, "On Behalf-Org Logo", $text_color); imagepng($im,"/tmp/file.png"); - + $imagePath = "/tmp/file.png"; $this->webtestAttachFile('onbehalf_image_URL', $imagePath); unlink($imagePath); @@ -1569,11 +1494,11 @@ class WebTest_Contribute_OnBehalfOfOrganization extends CiviSeleniumTestCase { // Wait for result list. $this->waitForElementPresent("css=div.ac_results-inner li"); - + // Visit organization page. $this->click("css=div.ac_results-inner li"); $this->waitForPageToLoad($this->getTimeoutMsec()); - + //check whether the image is present $this->assertTrue($this->isElementPresent("xpath=//div[@id='crm-contact-thumbnail']/div/a/img")); } diff --git a/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php b/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php index 7be85289ef..b8f5fa61dc 100644 --- a/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OnlineContributionTest.php @@ -33,36 +33,26 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase { } function testOnlineContributionAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // We need a payment processor $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $processorType = 'Dummy'; - $pageTitle = substr(sha1(rand()), 0, 7); - $rand = 2 * rand(10, 50); - $hash = substr(sha1(rand()), 0, 7); + $pageTitle = substr(sha1(rand()), 0, 7); + $rand = 2 * rand(10, 50); + $hash = substr(sha1(rand()), 0, 7); $amountSection = TRUE; - $payLater = FALSE; - $onBehalf = FALSE; - $pledges = FALSE; - $recurring = FALSE; - $memberships = FALSE; - $friend = TRUE; - $profilePreId = 1; + $payLater = FALSE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = FALSE; + $memberships = FALSE; + $friend = TRUE; + $profilePreId = 1; $profilePostId = NULL; - $premiums = FALSE; - $widget = FALSE; - $pcp = FALSE; + $premiums = FALSE; + $widget = FALSE; + $pcp = FALSE; $memPriceSetId = NULL; // create a new online contribution page @@ -87,8 +77,7 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase { ); //logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); //Open Live Contribution Page $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=" . $pageId); @@ -151,15 +140,12 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check contribution - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); //Find Contribution - $this->open($this->sboxPath . "civicrm/contribute/search?reset=1"); - - $this->waitForElementPresent("contribution_date_low"); + $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); $this->type("sort_name", "$firstName $lastName"); $this->click("_qf_Search_refresh"); @@ -173,11 +159,11 @@ class WebTest_Contribute_OnlineContributionTest extends CiviSeleniumTestCase { //View Contribution Record and verify data $expected = array( - 'From' => "{$firstName} {$lastName}", - 'Financial Type' => 'Donation', - 'Total Amount' => '100.00', + 'From' => "{$firstName} {$lastName}", + 'Financial Type' => 'Donation', + 'Total Amount' => '100.00', 'Contribution Status' => 'Completed', - 'In Honor of' => $honorDisplayName + 'In Honor of' => $honorDisplayName ); $this->webtestVerifyTabularData($expected); diff --git a/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php b/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php index ca617bf500..3b9ddd9367 100644 --- a/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php +++ b/tests/phpunit/WebTest/Contribute/OnlineMultiplePaymentProcessorTest.php @@ -32,7 +32,6 @@ class WebTest_Contribute_OnlineMultiplePaymentProcessorTest extends CiviSelenium } function testOnlineMultpiplePaymentProcessor() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -116,12 +115,10 @@ class WebTest_Contribute_OnlineMultiplePaymentProcessorTest extends CiviSelenium $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check contribution - $this->open($this->sboxPath); } function testOnlineMultiplePaymentProcessorWithPayLater() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -197,9 +194,7 @@ class WebTest_Contribute_OnlineMultiplePaymentProcessorTest extends CiviSelenium $this->assertTrue($this->isTextPresent($payLaterInstructionsText)); //login to check contribution - $this->open($this->sboxPath . 'civicrm/contribute/search?reset=1'); - - $this->waitForElementPresent('contribution_date_low'); + $this->openCiviPage("contribute/search", "reset=1", 'contribution_date_low'); $this->type('sort_name', "$firstName $lastName"); $this->check('contribution_test'); diff --git a/tests/phpunit/WebTest/Contribute/OnlineRecurContributionTest.php b/tests/phpunit/WebTest/Contribute/OnlineRecurContributionTest.php index d272386d94..5bef9daf1b 100644 --- a/tests/phpunit/WebTest/Contribute/OnlineRecurContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/OnlineRecurContributionTest.php @@ -36,27 +36,26 @@ class WebTest_Contribute_OnlineRecurContributionTest extends CiviSeleniumTestCas require_once 'ContributionPageAddTest.php'; // a random 7-char string and an even number to make this pass unique - $hash = substr(sha1(rand()), 0, 7); - $rand = $contributionAmount = 2 * rand(2, 50); - $pageTitle = 'Donate Online Recurring ' . $hash; + $hash = substr(sha1(rand()), 0, 7); + $rand = $contributionAmount = 2 * rand(2, 50); + $pageTitle = 'Donate Online Recurring ' . $hash; $processorType = 'AuthNet'; $processorName = "Webtest AuthNet " . substr(sha1(rand()), 0, 7); $amountSection = TRUE; - $payLater = FALSE; - $onBehalf = FALSE; - $pledges = FALSE; - $recurring = TRUE; - $memberships = FALSE; + $payLater = FALSE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = TRUE; + $memberships = FALSE; $memPriceSetId = NULL; - $friend = TRUE; - $profilePreId = NULL; + $friend = TRUE; + $profilePreId = NULL; $profilePostId = NULL; - $premiums = FALSE; - $widget = FALSE; - $pcp = FALSE; + $premiums = FALSE; + $widget = FALSE; + $pcp = FALSE; // open browser, login - $this->open($this->sboxPath); $this->webtestLogin(); // create a new online contribution page with recurring enabled (using a newly created AuthNet processor) @@ -81,17 +80,15 @@ class WebTest_Contribute_OnlineRecurContributionTest extends CiviSeleniumTestCas ); //now do the test online recurring contribution as an anonymous user. - $anonymous = TRUE; - $firstName = 'Jane' . substr(sha1(rand()), 0, 7); - $middleName = 'Middle'; - $lastName = 'Recuron_' . substr(sha1(rand()), 0, 7); - $email = $firstName . '@example.com'; + $anonymous = TRUE; + $firstName = 'Jane' . substr(sha1(rand()), 0, 7); + $middleName = 'Middle'; + $lastName = 'Recuron_' . substr(sha1(rand()), 0, 7); + $email = $firstName . '@example.com'; $contactName = "$firstName $lastName"; // logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - // Wait for Login button to indicate we've logged out. - $this->waitForElementPresent("edit-submit"); + $this->webtestLogout(); $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&action=preview&id=" . $pageId); $this->waitForElementPresent("_qf_Main_upload-bottom"); @@ -127,10 +124,8 @@ class WebTest_Contribute_OnlineRecurContributionTest extends CiviSeleniumTestCas $this->assertTrue($this->isTextPresent($contributionAmount), 'Missing contribution amount (thank-you): ' . $contributionAmount); // Log back in and verify that test contribution has been recorded - $this->open($this->sboxPath); $this->webtestLogin(); - $this->open($this->sboxPath . "civicrm/contribute/search?reset=1"); - $this->waitForElementPresent("contribution_currency_type"); + $this->openCiviPage("contribute/search", "reset=1", "contribution_currency_type"); $this->type("sort_name", "{$lastName}, {$firstName}"); $this->click("contribution_test"); @@ -143,7 +138,7 @@ class WebTest_Contribute_OnlineRecurContributionTest extends CiviSeleniumTestCas // View Recurring Contribution Record $verifyData = array( 'From' => "$contactName", - 'Financial Type' => 'Donation (test)', + 'Financial Type' => 'Donation (test)', 'Total Amount' => 'Installments: 12, Interval: 1 month(s)', 'Contribution Status' => 'Pending : Incomplete Transaction', 'Paid By' => 'Credit Card', diff --git a/tests/phpunit/WebTest/Contribute/PCPAddTest.php b/tests/phpunit/WebTest/Contribute/PCPAddTest.php index 5d3e2472fa..ae81fca4e4 100755 --- a/tests/phpunit/WebTest/Contribute/PCPAddTest.php +++ b/tests/phpunit/WebTest/Contribute/PCPAddTest.php @@ -33,17 +33,15 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { function testPCPAdd() { // open browser, login - $this->open($this->sboxPath); $this->webtestLogin(); // set pcp supporter name and email - $firstName = 'Ma' . substr(sha1(rand()), 0, 4); - $lastName = 'An' . substr(sha1(rand()), 0, 7); + $firstName = 'Ma' . substr(sha1(rand()), 0, 4); + $lastName = 'An' . substr(sha1(rand()), 0, 7); $middleName = 'Mid' . substr(sha1(rand()), 0, 7); - $email = substr(sha1(rand()), 0, 7) . '@example.org'; + $email = substr(sha1(rand()), 0, 7) . '@example.org'; - $this->open($this->sboxPath . 'civicrm/admin/domain?action=update&reset=1'); - $this->waitForElementPresent('_qf_Domain_cancel-bottom'); + $this->openCiviPage("admin/domain", "action=update&reset=1", '_qf_Domain_cancel-bottom'); $this->type('name', 'DefaultDomain'); $this->type('email_name', $firstName); $this->type('email_address', $email); @@ -57,24 +55,24 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { require_once 'ContributionPageAddTest.php'; // a random 7-char string and an even number to make this pass unique - $hash = substr(sha1(rand()), 0, 7); - $rand = $contributionAmount = 2 * rand(2, 50); - $pageTitle = 'PCP Contribution' . $hash; - $processorType = 'Dummy'; - $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); - $amountSection = TRUE; - $payLater = TRUE; - $onBehalf = FALSE; - $pledges = FALSE; - $recurring = FALSE; - $memberships = FALSE; - $memPriceSetId = NULL; - $friend = FALSE; - $profilePreId = NULL; - $profilePostId = NULL; - $premiums = FALSE; - $widget = FALSE; - $pcp = TRUE; + $hash = substr(sha1(rand()), 0, 7); + $rand = $contributionAmount = 2 * rand(2, 50); + $pageTitle = 'PCP Contribution' . $hash; + $processorType = 'Dummy'; + $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); + $amountSection = TRUE; + $payLater = TRUE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = FALSE; + $memberships = FALSE; + $memPriceSetId = NULL; + $friend = FALSE; + $profilePreId = NULL; + $profilePostId = NULL; + $premiums = FALSE; + $widget = FALSE; + $pcp = TRUE; $isAprovalNeeded = TRUE; // create a new online contribution page with pcp enabled @@ -101,12 +99,9 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { ); // logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - // Wait for Login button to indicate we've logged out. - $this->waitForElementPresent("edit-submit"); + $this->webtestLogout(); - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=" . $pageId); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage('contribute/transact', "reset=1&id=$pageId", "_qf_Main_upload-bottom"); $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input"); $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount); @@ -121,8 +116,7 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { $this->click("_qf_Confirm_next-bottom"); $this->waitForElementPresent("thankyou_footer"); - $this->open($this->sboxPath . "civicrm/contribute/campaign?action=add&reset=1&pageId=" . $pageId . "&component=contribute"); - $this->waitForElementPresent("_qf_PCPAccount_next-bottom"); + $this->openCiviPage("contribute/campaign", "action=add&reset=1&pageId={$pageId}&component=contribute", "_qf_PCPAccount_next-bottom"); $cmsUserName = 'CmsUser' . substr(sha1(rand()), 0, 7); $this->type("cms_name", $cmsUserName); @@ -146,10 +140,8 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { $this->type("goal_amount", $contributionAmount); $this->click("_qf_Campaign_upload-bottom"); - $this->open($this->sboxPath); $this->webtestLogin(); - $this->open($this->sboxPath . "civicrm/admin/pcp?reset=1"); - $this->waitForElementPresent("_qf_PCP_refresh"); + $this->openCiviPage("admin/pcp", "reset=1", "_qf_PCP_refresh"); $this->select('status_id', 'value=1'); $this->click("_qf_PCP_refresh"); $this->waitForElementPresent("_qf_PCP_refresh"); @@ -159,21 +151,17 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { $this->click("xpath=//td[@id=$pcpId]/span[1]/a[2]"); $this->waitForPageToLoad($this->getTimeoutMsec()); // logout - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - // Wait for Login button to indicate we've logged out. - $this->waitForElementPresent('edit-submit'); + $this->webtestLogout(); // Set pcp contributor name - $donorFirstName = 'Donor' . substr(sha1(rand()), 0, 4); - $donorLastName = 'Person' . substr(sha1(rand()), 0, 7); + $donorFirstName = 'Donor' . substr(sha1(rand()), 0, 4); + $donorLastName = 'Person' . substr(sha1(rand()), 0, 7); $middleName = 'Mid' . substr(sha1(rand()), 0, 7); $this->open($this->sboxPath . $pcpUrl); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=$pageId&pcpId=$id[1]"); - - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id=$pageId&pcpId=$id[1]", "_qf_Main_upload-bottom"); $this->click("xpath=//div[@class='crm-section other_amount-section']//div[2]/input"); $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", $contributionAmount); $this->type("email-5", $donorFirstName . "@example.com"); @@ -187,15 +175,12 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { $this->waitForElementPresent("thankyou_footer"); //login to check contribution - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); //Find Contribution - $this->open($this->sboxPath . "civicrm/contribute/search?reset=1"); - - $this->waitForElementPresent("contribution_date_low"); + $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); $this->select('contribution_pcp_made_through_id', "label={$pcpTitle}"); @@ -210,9 +195,9 @@ class WebTest_Contribute_PCPAddTest extends CiviSeleniumTestCase { // View Contribution Record and test for expected values $expected = array( - 'From' => "{$donorFirstName} {$donorLastName}", - 'Financial Type' => 'Donation', - 'Total Amount' => $contributionAmount, + 'From' => "{$donorFirstName} {$donorLastName}", + 'Financial Type' => 'Donation', + 'Total Amount' => $contributionAmount, 'Contribution Status' => 'Completed', ); $this->webtestVerifyTabularData($expected); diff --git a/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php b/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php index 2cc13c4eb7..5ca27b9175 100644 --- a/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Contribute/StandaloneAddTest.php @@ -33,16 +33,6 @@ class WebTest_Contribute_StandaloneAddTest extends CiviSeleniumTestCase { } function testStandaloneContributeAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Create a contact to be used as soft creditor @@ -79,14 +69,8 @@ class WebTest_Contribute_StandaloneAddTest extends CiviSeleniumTestCase { $isDefault ); - // Go directly to the URL of the screen that you will be testing (New Contribution-standalone). - $this->open($this->sboxPath . "civicrm/contribute/add?reset=1&context=standalone"); + $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload"); - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Contribution_upload"); - - // Let's start filling the form with values. // create new contact using dialog $firstName = substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php index fc52514780..1035301ead 100644 --- a/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateBatchPendingContributionTest.php @@ -33,24 +33,12 @@ class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSelenium } function testBatchUpdatePendingContribution() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $this->_testOfflineContribution(); $this->_testOfflineContribution(); $this->_testOfflineContribution(); - $this->open($this->sboxPath . "civicrm/contribute/search?reset=1"); - - $this->waitForElementPresent("contribution_date_low"); + $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); $this->type("sort_name", "Contributor"); $this->click('contribution_status_id_2'); @@ -84,11 +72,6 @@ class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSelenium } function testParticipationAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -105,8 +88,7 @@ class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSelenium $this->_addParticipant($firstName2); // Search the participants - $this->open($this->sboxPath . 'civicrm/event/search?reset=1'); - $this->waitForElementPresent('_qf_Search_refresh'); + $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh'); $eventName = 'Rain'; $this->click("event_name"); @@ -117,8 +99,7 @@ class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSelenium $this->assertContains($eventName, $this->getValue("event_name"), "autocomplete expected $eventName but didn’t find it in " . $this->getValue("event_name")); $this->click('_qf_Search_refresh'); - $this->open($this->sboxPath . "civicrm/contribute/search?reset=1"); - $this->waitForElementPresent("contribution_date_low"); + $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); $this->type("sort_name", "Anderson"); $this->click('contribution_status_id_2'); @@ -152,14 +133,9 @@ class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSelenium } function _addParticipant($firstName) { - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). - $this->open($this->sboxPath . 'civicrm/participant/add?reset=1&action=add&context=standalone'); - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent('_qf_Participant_upload-bottom'); + $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", '_qf_Participant_upload-bottom'); - // Let's start filling the form with values. // Type contact last name in contact auto-complete, wait for dropdown and click first result $this->webtestFillAutocomplete($firstName); @@ -219,14 +195,8 @@ class WebTest_Contribute_UpdateBatchPendingContributionTest extends CiviSelenium $lastName = 'Contributor'; $email = $firstName . "@example.com"; - // Go directly to the URL of the screen that you will be testing (New Contribution-standalone). - $this->open($this->sboxPath . "civicrm/contribute/add?reset=1&context=standalone"); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Contribution_upload"); + $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload"); - // Let's start filling the form with values. // create new contact using dialog $this->webtestNewDialogContact($firstName, "Contributor", $email); diff --git a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php index 28db4b4bdd..b50e8350e6 100644 --- a/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdateContributionTest.php @@ -50,9 +50,7 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { //Offline Pay Later Contribution $this->_testOfflineContribution($firstName, $lastName, $email, $amount, "Pending"); - $this->open($this->sboxPath . "civicrm/contribute/search?reset=1"); - - $this->waitForElementPresent("contribution_date_low"); + $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); $this->type("sort_name", "$lastName, $firstName"); $this->click("_qf_Search_refresh"); @@ -520,15 +518,9 @@ class WebTest_Contribute_UpdateContributionTest extends CiviSeleniumTestCase { return $result; } - function _testOfflineContribution($firstName, $lastName, $email, $amount, $status="Completed") { - // Go directly to the URL of the screen that you will be testing (New Contribution-standalone). - $this->open($this->sboxPath . "civicrm/contribute/add?reset=1&context=standalone"); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Contribution_upload"); + function _testOfflineContribution($firstName, $lastName, $email, $amount, $status="Completed") { - // Let's start filling the form with values. + $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload"); // create new contact using dialog $this->webtestNewDialogContact($firstName, $lastName, $email); diff --git a/tests/phpunit/WebTest/Contribute/UpdatePendingContributionTest.php b/tests/phpunit/WebTest/Contribute/UpdatePendingContributionTest.php index 9d175ac82f..8c81f556ee 100644 --- a/tests/phpunit/WebTest/Contribute/UpdatePendingContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/UpdatePendingContributionTest.php @@ -33,29 +33,17 @@ class WebTest_Contribute_UpdatePendingContributionTest extends CiviSeleniumTestC } function testUpdatePendingContribution() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $firstName = substr(sha1(rand()), 0, 7); - $lastName = 'Contributor'; - $email = $firstName . "@example.com"; + $lastName = 'Contributor'; + $email = $firstName . "@example.com"; //Offline Pay Later Contribution $this->_testOfflineContribution($firstName, $lastName, $email); //Online Pay Later Contribution $this->_testOnlineContribution($firstName, $lastName, $email); - $this->open($this->sboxPath . "civicrm/contribute/search?reset=1"); - - $this->waitForElementPresent("contribution_date_low"); + $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); $this->type("sort_name", "$lastName, $firstName"); $this->click("_qf_Search_refresh"); @@ -91,14 +79,8 @@ class WebTest_Contribute_UpdatePendingContributionTest extends CiviSeleniumTestC $softCreditLname = substr(sha1(rand()), 0, 7); $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE); - // Go directly to the URL of the screen that you will be testing (New Contribution-standalone). - $this->open($this->sboxPath . "civicrm/contribute/add?reset=1&context=standalone"); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent("_qf_Contribution_upload"); + $this->openCiviPage("contribute/add", "reset=1&context=standalone", "_qf_Contribution_upload"); - // Let's start filling the form with values. // create new contact using dialog $this->webtestNewDialogContact($firstName, "Contributor", $email); @@ -213,21 +195,21 @@ class WebTest_Contribute_UpdatePendingContributionTest extends CiviSeleniumTestC // We need a payment processor $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $processorType = 'Dummy'; - $pageTitle = substr(sha1(rand()), 0, 7); - $rand = 2 * rand(2, 50); - $hash = substr(sha1(rand()), 0, 7); + $pageTitle = substr(sha1(rand()), 0, 7); + $rand = 2 * rand(2, 50); + $hash = substr(sha1(rand()), 0, 7); $amountSection = TRUE; - $payLater = TRUE; - $onBehalf = FALSE; - $pledges = FALSE; - $recurring = FALSE; - $memberships = FALSE; - $friend = FALSE; - $profilePreId = 1; + $payLater = TRUE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = FALSE; + $memberships = FALSE; + $friend = FALSE; + $profilePreId = 1; $profilePostId = NULL; - $premiums = FALSE; - $widget = FALSE; - $pcp = FALSE; + $premiums = FALSE; + $widget = FALSE; + $pcp = FALSE; $memPriceSetId = NULL; // create a new online contribution page @@ -252,12 +234,8 @@ class WebTest_Contribute_UpdatePendingContributionTest extends CiviSeleniumTestC ); //logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=" . $pageId); - $this->waitForElementPresent("_qf_Main_upload-bottom"); - - + $this->webtestLogout(); + $this->openCiviPage("contribute/transact", "reset=1&id=$pageId", "_qf_Main_upload-bottom"); $this->type("email-5", $email); @@ -274,7 +252,6 @@ class WebTest_Contribute_UpdatePendingContributionTest extends CiviSeleniumTestC $this->select("country-1", "value=1228"); $this->select("state_province-1", "value=1001"); - $this->click("_qf_Main_upload-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -283,16 +260,11 @@ class WebTest_Contribute_UpdatePendingContributionTest extends CiviSeleniumTestC $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - //login to check contribution - $this->open($this->sboxPath); - - // Log in using webtestLogin() method + //login to check contribution $this->webtestLogin(); //Find Contribution - $this->open($this->sboxPath . "civicrm/contribute/search?reset=1"); - - $this->waitForElementPresent("contribution_date_low"); + $this->openCiviPage("contribute/search", "reset=1", "contribution_date_low"); $this->type("sort_name", "$lastName, $firstName"); $this->click("_qf_Search_refresh"); @@ -305,9 +277,9 @@ class WebTest_Contribute_UpdatePendingContributionTest extends CiviSeleniumTestC $this->waitForElementPresent("_qf_ContributionView_cancel-bottom"); // View Contribution Record and test for expected values $expected = array( - 'From' => "{$firstName} {$lastName}", - 'Financial Type' => 'Donation', - 'Total Amount' => '100.00', + 'From' => "{$firstName} {$lastName}", + 'Financial Type' => 'Donation', + 'Total Amount' => '100.00', 'Contribution Status' => 'Pending : Pay Later', ); $this->webtestVerifyTabularData($expected); diff --git a/tests/phpunit/WebTest/Contribute/VerifySSLContributionTest.php b/tests/phpunit/WebTest/Contribute/VerifySSLContributionTest.php index 2b1f4b9475..1f91a81829 100644 --- a/tests/phpunit/WebTest/Contribute/VerifySSLContributionTest.php +++ b/tests/phpunit/WebTest/Contribute/VerifySSLContributionTest.php @@ -49,8 +49,7 @@ class WebTest_Contribute_VerifySSLContributionTest extends CiviSeleniumTestCase function _initialize() { if (!$this->initialized) { // log in - $this->open($this->sboxPath); - $this->webtestLogin(); + $this->webtestLogin(); // build names $hash = substr(sha1(rand()), 0, 7); @@ -104,9 +103,7 @@ class WebTest_Contribute_VerifySSLContributionTest extends CiviSeleniumTestCase function _tryPaymentProcessor($name) { // load contribution page - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&action=preview&id={$this->pageId}"); - $this->waitForPageToLoad("3000"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&action=preview&id={$this->pageId}", "_qf_Main_upload-bottom"); // fill out info $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", "30"); diff --git a/tests/phpunit/WebTest/Event/AddEventTest.php b/tests/phpunit/WebTest/Event/AddEventTest.php index 6463e7b090..f3b5ec2ea3 100644 --- a/tests/phpunit/WebTest/Event/AddEventTest.php +++ b/tests/phpunit/WebTest/Event/AddEventTest.php @@ -33,11 +33,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function testAddPaidEventNoTemplate() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -45,7 +40,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -76,7 +70,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function testAddPaidEventDiscount() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -85,7 +78,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -117,7 +109,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function testDeletePriceSetDiscount() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -126,7 +117,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -152,8 +142,7 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $registerUrl = $this->_testVerifyRegisterPage($registerStrings); //Add Price Set now - $this->open($this->sboxPath . "civicrm/event/manage/fee?reset=1&action=update&id=$id"); - $this->waitForElementPresent("_qf_Fee_upload-bottom"); + $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom"); $this->click("xpath=//a[@id='quickconfig']"); $this->waitForElementPresent('popupContainer'); sleep(3); @@ -167,7 +156,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function testAddDeleteEventDiscount() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -176,7 +164,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -205,8 +192,7 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function _deleteDiscount($id, $eventTitle, $discount) { - $this->open($this->sboxPath . "civicrm/event/manage/fee?reset=1&action=update&id=$id"); - $this->waitForElementPresent("_qf_Fee_upload-bottom"); + $this->openCiviPage("event/manage/fee", "reset=1&action=update&id=$id", "_qf_Fee_upload-bottom"); $this->type("discount_name_2", ""); $this->click("xpath=//tr[@id='discount_2']/td[3]/span/a"); $this->click("xpath=//tr[@id='discount_2']/td[4]/span/a"); @@ -222,7 +208,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function testAddPaidEventWithTemplate() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -231,7 +216,6 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -259,12 +243,10 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function testAddFreeEventWithTemplate() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); - - // Go directly to the URL of the screen that you will be testing (New Event). + $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Free Meeting - ' . substr(sha1(rand()), 0, 7); @@ -297,12 +279,10 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function testUnpaidPaid() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Event). $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); $eventDescription = "Here is a description for this conference."; @@ -326,11 +306,8 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function _testAddEventInfo($eventTitle, $eventDescription) { - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - // Let's start filling the form with values. $this->select("event_type_id", "value=1"); // Attendee role s/b selected now. @@ -356,11 +333,8 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } function _testAddEventInfoFromTemplate($eventTitle, $eventDescription, $templateID, $eventTypeID) { - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - - // Let's start filling the form with values. + // Select event template. Use option value, not label - since labels can be translated and test would fail $this->select("template_id", "value={$templateID}"); @@ -530,8 +504,7 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) { if ($anonymous) { - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); } $this->open($registerUrl); @@ -615,4 +588,4 @@ class WebTest_Event_AddEventTest extends CiviSeleniumTestCase { } } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Event/AddParticipationTest.php b/tests/phpunit/WebTest/Event/AddParticipationTest.php index 70c65c3dc1..fd24855fac 100644 --- a/tests/phpunit/WebTest/Event/AddParticipationTest.php +++ b/tests/phpunit/WebTest/Event/AddParticipationTest.php @@ -33,11 +33,6 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase { } function testEventParticipationAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -48,10 +43,8 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase { $contactName = "Anderson, $firstName"; $displayName = "$firstName Anderson"; - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom"); - // Let's start filling the form with values. // Type contact last name in contact auto-complete, wait for dropdown and click first result $this->webtestFillAutocomplete($firstName); @@ -133,11 +126,6 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase { function testEventParticipationAddWithMultipleRoles() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -251,10 +239,8 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase { $this->click('_qf_Field_next'); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom"); - // Let's start filling the form with values. // Type contact last name in contact auto-complete, wait for dropdown and click first result $this->webtestFillAutocomplete($firstName); @@ -341,12 +327,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase { ); } - function testEventAddMultipleParticipants() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - + function testEventAddMultipleParticipants() { // Log in using webtestLogin() method $this->webtestLogin(); @@ -356,8 +337,7 @@ class WebTest_Event_AddParticipationTest extends CiviSeleniumTestCase { $lastName = 'Last' . $rand; $rand = substr(sha1(rand()), 0, 7); $lastName2 = 'Last' . $rand; - - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). + $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone&mode=test&eid=3"); $this->assertTrue($this->isTextPresent("Register New Participant"), "Page title 'Register New Participant' missing"); diff --git a/tests/phpunit/WebTest/Event/AddPricesetTest.php b/tests/phpunit/WebTest/Event/AddPricesetTest.php index 3d60e2b42a..67bd75aa26 100644 --- a/tests/phpunit/WebTest/Event/AddPricesetTest.php +++ b/tests/phpunit/WebTest/Event/AddPricesetTest.php @@ -38,8 +38,8 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { $this->webtestLogin(); $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); - $usedFor = 'Event'; - $setHelp = 'Select your conference options.'; + $usedFor = 'Event'; + $setHelp = 'Select your conference options.'; $this->_testAddSet($setTitle, $usedFor, $setHelp); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -186,13 +186,12 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { } function testRegisterWithPriceSet() { - // Log in using webtestLogin() method $this->webtestLogin(); $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); - $usedFor = 'Event'; - $setHelp = 'Select your conference options.'; + $usedFor = 'Event'; + $setHelp = 'Select your conference options.'; $this->_testAddSet($setTitle, $usedFor, $setHelp); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -217,14 +216,12 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); - $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); - $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com'; + $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); + $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com'; $eventDescription = 'Here is a description for this conference.'; - // Let's start filling the form with values. $this->select('event_type_id', 'value=1'); // Attendee role s/b selected now. @@ -289,7 +286,7 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $eventInfoUrl = $this->getLocation(); - $this->openCiviPage('logout', 'reset=1', NULL); + $this->webtestLogout(); $this->open($eventInfoUrl); $this->click('link=Register Now'); $this->waitForElementPresent('_qf_Register_upload-bottom'); @@ -357,8 +354,8 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { $this->webtestLogin(); $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); - $usedFor = 'Event'; - $setHelp = 'Select your conference options.'; + $usedFor = 'Event'; + $setHelp = 'Select your conference options.'; $this->_testAddSet($setTitle, $usedFor, $setHelp); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -383,14 +380,12 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { $processorName = 'Webtest Dummy' . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); - $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); - $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com'; + $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); + $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com'; $eventDescription = 'Here is a description for this conference.'; - // Let's start filling the form with values. $this->select('event_type_id', 'value=1'); // Attendee role s/b selected now. @@ -460,10 +455,8 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { $contactName = "Anderson, $firstName"; $displayName = "$firstName Anderson"; - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). $this->openCiviPage('participant/add', 'reset=1&action=add&context=standalone', '_qf_Participant_upload-bottom'); - // Let's start filling the form with values. // Type contact last name in contact auto-complete, wait for dropdown and click first result $this->webtestFillAutocomplete($firstName); @@ -515,8 +508,8 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { $displayName = "$firstName Anderson"; $setTitle = 'Conference Fees - ' . substr(sha1(rand()), 0, 7); - $usedFor = 'Event'; - $setHelp = 'Select your conference options.'; + $usedFor = 'Event'; + $setHelp = 'Select your conference options.'; $this->_testAddSet($setTitle, $usedFor, $setHelp); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -535,15 +528,13 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { // load the Price Set Preview and check for expected values $this->_testVerifyPriceSet($validateStrings, $sid); - - // Go directly to the URL of the screen that you will be testing (New Event). + $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); - $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); - $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com'; + $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); + $email = 'Smith' . substr(sha1(rand()), 0, 7) . '@example.com'; $eventDescription = 'Here is a description for this conference.'; - // Let's start filling the form with values. $this->select('event_type_id', 'value=1'); // Attendee role s/b selected now. @@ -578,10 +569,8 @@ class WebTest_Event_AddPricesetTest extends CiviSeleniumTestCase { $this->click('_qf_Fee_upload-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). - $this->openCiviPage('participant/add', 'reset=1&action=add&context=standalone', '_qf_Participant_upload-bottom'); + $this->openCiviPage('participant/add', 'reset=1&action=add&context=standalone', '_qf_Participant_upload-bottom'); - // Let's start filling the form with values. // Type contact last name in contact auto-complete, wait for dropdown and click first result $this->webtestFillAutocomplete($firstName); $this->select('event_id', "label=regexp:$eventTitle"); diff --git a/tests/phpunit/WebTest/Event/ChangeParticipantStatus.php b/tests/phpunit/WebTest/Event/ChangeParticipantStatus.php index c8e6e9c422..77f5c1e0cd 100644 --- a/tests/phpunit/WebTest/Event/ChangeParticipantStatus.php +++ b/tests/phpunit/WebTest/Event/ChangeParticipantStatus.php @@ -33,11 +33,6 @@ class WebTest_Event_ChangeParticipantStatus extends CiviSeleniumTestCase { } function testParticipationAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -54,8 +49,7 @@ class WebTest_Event_ChangeParticipantStatus extends CiviSeleniumTestCase { $this->addParticipant($firstName2); // Search the participants - $this->open($this->sboxPath . 'civicrm/event/search?reset=1'); - $this->waitForElementPresent('_qf_Search_refresh'); + $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh'); $eventName = 'Rain'; $this->click("event_name"); @@ -88,8 +82,7 @@ class WebTest_Event_ChangeParticipantStatus extends CiviSeleniumTestCase { ); // Verify the changed status - $this->open($this->sboxPath . 'civicrm/event/search?reset=1'); - $this->waitForElementPresent('_qf_Search_refresh'); + $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh'); $this->type('sort_name', $firstName1); $this->click('_qf_Search_refresh'); $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName1']"); @@ -97,8 +90,7 @@ class WebTest_Event_ChangeParticipantStatus extends CiviSeleniumTestCase { $this->waitForElementPresent('_qf_ParticipantView_cancel-bottom'); $this->webtestVerifyTabularData(array('Status' => 'Attended')); - $this->open($this->sboxPath . 'civicrm/event/search?reset=1'); - $this->waitForElementPresent('_qf_Search_refresh'); + $this->openCiviPage("event/search", "reset=1", '_qf_Search_refresh'); $this->type('sort_name', $firstName2); $this->click('_qf_Search_refresh'); $this->waitForElementPresent("xpath=//div[@id='participantSearch']/table/tbody//tr/td[3]/a[text()='$sortName2']"); @@ -108,14 +100,8 @@ class WebTest_Event_ChangeParticipantStatus extends CiviSeleniumTestCase { } function addParticipant($firstName) { - // Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone). - $this->open($this->sboxPath . 'civicrm/participant/add?reset=1&action=add&context=standalone'); - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. - $this->waitForElementPresent('_qf_Participant_upload-bottom'); + $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", '_qf_Participant_upload-bottom'); - // Let's start filling the form with values. // Type contact last name in contact auto-complete, wait for dropdown and click first result $this->webtestFillAutocomplete($firstName); diff --git a/tests/phpunit/WebTest/Event/EventListingTest.php b/tests/phpunit/WebTest/Event/EventListingTest.php index 4839502cf4..a560e664d0 100644 --- a/tests/phpunit/WebTest/Event/EventListingTest.php +++ b/tests/phpunit/WebTest/Event/EventListingTest.php @@ -7,13 +7,8 @@ class WebTest_Event_EventListingTest extends CiviSeleniumTestCase { } function testEventListing() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); //Closed Event $eventTitle1 = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -84,8 +79,8 @@ class WebTest_Event_EventListingTest extends CiviSeleniumTestCase { //go to block listing to enable Upcomming Events Block // you need to be admin user for below operation - $this->openCiviPage("logout", "reset=1", NULL); - $this->webtestLogin(TRUE); + $this->webtestLogout(); + $this->webtestLogin('admin'); $this->open($this->sboxPath . 'admin/structure/block/manage/civicrm/6/configure'); $this->waitForElementPresent('edit-submit'); @@ -115,17 +110,13 @@ class WebTest_Event_EventListingTest extends CiviSeleniumTestCase { } function _testCreateEvent($eventTitle, $startdate, $enddate) { - // Go directly to the URL of the screen that you will be testing (New Event). + $this->openCiviPage("event/add", "reset=1&action=add"); // $eventTitle = 'My Conference - '.substr(sha1(rand()), 0, 7); $eventDescription = "Here is a description for this conference."; - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - // Let's start filling the form with values. $this->select("event_type_id", "value=1"); // Attendee role s/b selected now. diff --git a/tests/phpunit/WebTest/Event/EventWaitListTest.php b/tests/phpunit/WebTest/Event/EventWaitListTest.php index c8b362c96a..d8c4aa9581 100644 --- a/tests/phpunit/WebTest/Event/EventWaitListTest.php +++ b/tests/phpunit/WebTest/Event/EventWaitListTest.php @@ -31,11 +31,6 @@ class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase { } function testEventWaitList() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -43,17 +38,12 @@ class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase { $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - // Go directly to the URL of the screen that you will be testing (New Event). $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); $eventDescription = "Here is a description for this conference."; - - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - // Let's start filling the form with values. $this->select("event_type_id", "value=1"); // Attendee role s/b selected now. @@ -184,8 +174,7 @@ class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase { function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) { if ($anonymous) { - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); } $this->open($registerUrl); @@ -227,7 +216,6 @@ class WebTest_Event_EventWaitListTest extends CiviSeleniumTestCase { if ($anonymous) { // log back in so we're in the same state - $this->open($this->sboxPath); $this->webtestLogin(); } } diff --git a/tests/phpunit/WebTest/Event/MultipleEventRegistrationbyCartTest.php b/tests/phpunit/WebTest/Event/MultipleEventRegistrationbyCartTest.php index 163cbdb2e3..0993db33d2 100755 --- a/tests/phpunit/WebTest/Event/MultipleEventRegistrationbyCartTest.php +++ b/tests/phpunit/WebTest/Event/MultipleEventRegistrationbyCartTest.php @@ -32,12 +32,7 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest parent::setUp(); } - function testAuthenticatedMultipleEvent(){ - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - + function testAuthenticatedMultipleEvent(){ // Log in using webtestLogin() method $this->webtestLogin(); @@ -53,7 +48,7 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest $this->webtestAddPaymentProcessor($processorName); //event 1 - // Go directly to the URL of the screen that you will be testing (New Event). + $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle1 = 'My Conference1 - ' . substr(sha1(rand()), 0, 7); @@ -74,7 +69,7 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest $this->_AddEventToCart($eventTitle1, $eventInfoStrings1); //event 2 - // Go directly to the URL of the screen that you will be testing (New Event). + $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle2 = 'My Conference2 - ' . substr(sha1(rand()), 0, 7); @@ -95,7 +90,7 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest $this->_AddEventToCart($eventTitle2, $eventInfoStrings2); //event 3 - // Go directly to the URL of the screen that you will be testing (New Event). + $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle3 = 'My Conference3 - ' . substr(sha1(rand()), 0, 7); @@ -131,7 +126,6 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest // This is the path where our testing install resides. // The rest of URL is defined in CiviSeleniumTestCase base class, in // class attributes. - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -141,7 +135,7 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest $this->webtestAddPaymentProcessor($processorName); //event 1 - // Go directly to the URL of the screen that you will be testing (New Event). + $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle1 = 'My Conference1 - ' . substr(sha1(rand()), 0, 7); @@ -162,7 +156,7 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest $registerUrl1 = $this->_testVerifyEventInfo($eventTitle1, $eventInfoStrings1); //event 2 - // Go directly to the URL of the screen that you will be testing (New Event). + $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle2 = 'My Conference2 - ' . substr(sha1(rand()), 0, 7); @@ -183,7 +177,7 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest $registerUrl2 = $this->_testVerifyEventInfo($eventTitle2, $eventInfoStrings2); //event 3 - // Go directly to the URL of the screen that you will be testing (New Event). + $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle3 = 'My Conference3 - ' . substr(sha1(rand()), 0, 7); @@ -231,11 +225,8 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest } function _testAddEventInfo($eventTitle, $eventDescription) { - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - // Let's start filling the form with values. $this->select("event_type_id", "value=1"); // Attendee role s/b selected now. @@ -370,19 +361,18 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest } return $this->getLocation(); } - + function _testOnlineRegistration($registerUrl, $numberRegistrations = 1, $anonymous = TRUE) { if ($anonymous) { - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); } $this->open($registerUrl); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->waitForElementPresent("link=Add to Cart"); $this->click("link=Add to Cart"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->waitForPageToLoad($this->getTimeoutMsec()); } - + function _testCheckOut(){ //View the Cart $this->click("xpath=//div[@id='messages']/div/div/a[text()='View your cart.']"); @@ -419,7 +409,7 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertTrue($this->isTextPresent("This is your receipt of payment made for the following event registration.")); - return array($firstName,$lastName); + return array($firstName, $lastName); } function _checkContributionsandEventRegistration($firstName,$lastName,$events){ @@ -473,4 +463,4 @@ class WebTest_Event_MultipleEventRegistrationbyCartTest extends CiviSeleniumTest $this->click("enable_cart"); $this->click("_qf_Event_next-top"); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Event/MultiprofileEventTest.php b/tests/phpunit/WebTest/Event/MultiprofileEventTest.php index 8290250be1..0c10b2666f 100644 --- a/tests/phpunit/WebTest/Event/MultiprofileEventTest.php +++ b/tests/phpunit/WebTest/Event/MultiprofileEventTest.php @@ -33,21 +33,16 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { } function testCreateEventRegisterPage() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); - $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7); - $firstName = 'Ma' . substr(sha1(rand()), 0, 4); - $lastName = 'An' . substr(sha1(rand()), 0, 7); + $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7); + $firstName = 'Ma' . substr(sha1(rand()), 0, 4); + $lastName = 'An' . substr(sha1(rand()), 0, 7); $participantfname = 'Dany' . substr(sha1(rand()), 0, 4); $participantlname = 'Dan' . substr(sha1(rand()), 0, 4); - $email1 = $firstName . "@test.com"; - $email2 = $participantfname . "@test.com"; + $email1 = $firstName . "@test.com"; + $email2 = $participantfname . "@test.com"; // We need a payment processor $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); @@ -73,7 +68,6 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { $profileId = $this->_testGetProfileId($customId); - // Go directly to the URL of the screen that you will be testing (New Event). $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -150,35 +144,26 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("_qf_DeleteGroup_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - - // logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); } function testAnoumyousRegisterPage() { - $this->open($this->sboxPath); - - // Log in using webtestLogin() method - $this->webtestLogin(TRUE); - // add the required Drupal permission $permission = array('edit-1-access-all-custom-data'); $this->changePermissions($permission); - $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7); - $firstName = 'Ma' . substr(sha1(rand()), 0, 4); - $lastName = 'An' . substr(sha1(rand()), 0, 7); - $participantfname = 'Dany' . substr(sha1(rand()), 0, 4); - $participantlname = 'Dan' . substr(sha1(rand()), 0, 4); - $email1 = $firstName . "@test.com"; - $email2 = $participantfname . "@test.com"; - $firstName2 = 'Man' . substr(sha1(rand()), 0, 4); - $lastName2 = 'Ann' . substr(sha1(rand()), 0, 7); + $customGrp1 = "Custom Data1_" . substr(sha1(rand()), 0, 7); + $firstName = 'Ma' . substr(sha1(rand()), 0, 4); + $lastName = 'An' . substr(sha1(rand()), 0, 7); + $participantfname = 'Dany' . substr(sha1(rand()), 0, 4); + $participantlname = 'Dan' . substr(sha1(rand()), 0, 4); + $email1 = $firstName . "@test.com"; + $email2 = $participantfname . "@test.com"; + $firstName2 = 'Man' . substr(sha1(rand()), 0, 4); + $lastName2 = 'Ann' . substr(sha1(rand()), 0, 7); $participantfname2 = 'Adam' . substr(sha1(rand()), 0, 4); $participantlname2 = 'Gil' . substr(sha1(rand()), 0, 4); - $email3 = $participantfname2 . "@test.com"; - $email4 = $firstName2 . "@test.com"; + $email3 = $participantfname2 . "@test.com"; + $email4 = $firstName2 . "@test.com"; // We need a payment processor $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); @@ -204,8 +189,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { $profileId = $this->_testGetProfileId($customId); - // Go directly to the URL of the screen that you will be testing (New Event). - $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); + $this->openCiviPage('event/add', "reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); $eventDescription = "Here is a description for this conference."; @@ -219,8 +203,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { $eventPageId = $this->_testAddMultipleProfile($profileId); // logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); $this->_testEventRegistration($eventPageId, $customId, $firstName, $lastName, $participantfname, $participantlname, $email1, $email2); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -265,8 +248,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { $this->_testRemoveProfile($eventPageId); // logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); $this->_testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -275,7 +257,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { $this->webtestLogin(); // Find Main Participant - $this->open($this->sboxPath . "civicrm/event/search?reset=1"); + $this->openCiviPage('event/search', "reset=1"); $this->type("sort_name", $firstName2); $this->click("_qf_Search_refresh"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -398,8 +380,8 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { 'supplemental_address_1' => 'supplemental_address_1', 'city' => 'city', ); - $location = 1; - $type = "Contact"; + $location = 1; + $type = "Contact"; $profileId1 = $this->_testCreateProfile($profilefield, $location, $type); array_push($profileId, $profileId1); @@ -409,8 +391,8 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { 'phone' => 'phone', 'postal_code' => 'postal_code', ); - $location = 0; - $type = "Contact"; + $location = 0; + $type = "Contact"; $profileId2 = $this->_testCreateProfile($profilefield, $location, $type); array_push($profileId, $profileId2); @@ -418,8 +400,8 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { 'nick_name' => 'nick_name', 'url' => 'url', ); - $location = 0; - $type = "Contact"; + $location = 0; + $type = "Contact"; $profileId3 = $this->_testCreateProfile($profilefield, $location, $type); array_push($profileId, $profileId3); @@ -427,8 +409,8 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { 'current_employer' => 'current_employer', 'job_title' => 'job_title', ); - $location = 0; - $type = "Individual"; + $location = 0; + $type = "Individual"; $profileId4 = $this->_testCreateProfile($profilefield, $location, $type); array_push($profileId, $profileId4); @@ -436,8 +418,8 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { 'middle_name' => 'middle_name', 'gender' => 'gender', ); - $location = 0; - $type = "Individual"; + $location = 0; + $type = "Individual"; $profileId5 = $this->_testCreateProfile($profilefield, $location, $type); array_push($profileId, $profileId5); @@ -446,16 +428,16 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { 'custom_' . $customId[1] => 'custom_' . $customId[1], 'custom_' . $customId[2] => 'custom_' . $customId[2], ); - $location = 0; - $type = "Contact"; + $location = 0; + $type = "Contact"; $profileId6 = $this->_testCreateProfile($profilefield, $location, $type); array_push($profileId, $profileId6); $profilefield = array( 'participant_role' => 'participant_role', ); - $location = 0; - $type = "Participant"; + $location = 0; + $type = "Participant"; $profileId7 = $this->_testCreateProfile($profilefield, $location, $type); array_push($profileId, $profileId7); @@ -474,8 +456,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { 'postal_code', ); - // Go directly to the URL of the screen that you will be - // testing (Add new profile ). + // Add new profile. $profilename = "Profile_" . substr(sha1(rand()), 0, 7); $this->open($this->sboxPath . 'civicrm/admin/uf/group?reset=1'); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -511,11 +492,8 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { } function _testAddEventInfo($eventTitle, $eventDescription) { - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - // Let's start filling the form with values. $this->select("event_type_id", "value=1"); // Attendee role s/b selected now. @@ -664,8 +642,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { function _testEventRegistration($eventPageId, $customId, $firstName, $lastName, $participantfname, $participantlname, $email1, $email2 ) { - $this->open($this->sboxPath . 'civicrm/event/register?id=' . $eventPageId . '&reset=1'); - $this->waitForElementPresent("_qf_Register_upload-bottom"); + $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom"); $this->select("additional_participants", "value=1"); $this->type("email-Primary", $email1); @@ -744,8 +721,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { } function _testEventRegistrationAfterRemoving($eventPageId, $customId, $firstName2, $lastName2, $participantfname2, $participantlname2, $email3, $email4) { - $this->open($this->sboxPath . 'civicrm/event/register?id=' . $eventPageId . '&reset=1'); - $this->waitForElementPresent("_qf_Register_upload-bottom"); + $this->openCiviPage("event/register", "id={$eventPageId}&reset=1", "_qf_Register_upload-bottom"); $this->select("additional_participants", "value=1"); $this->type("email-Primary", $email4); @@ -813,8 +789,7 @@ class WebTest_Event_MultiprofileEventTest extends CiviSeleniumTestCase { function _addEmailField( ){ //add email field in name and address profile - $this->open($this->sboxPath . "civicrm/admin/uf/group/field/add?reset=1&action=add&gid=1"); - $this->waitForElementPresent("_qf_Field_next-bottom"); + $this->openCiviPage('admin/uf/group/field/add', 'reset=1&action=add&gid=1', "_qf_Field_next-bottom"); $this->select("field_name[0]", "value=Contact"); $this->select("field_name[1]", "value=email"); $this->select("field_name[2]", "value=0"); diff --git a/tests/phpunit/WebTest/Event/PCPAddTest.php b/tests/phpunit/WebTest/Event/PCPAddTest.php index bc55c237eb..8949bdb3c4 100644 --- a/tests/phpunit/WebTest/Event/PCPAddTest.php +++ b/tests/phpunit/WebTest/Event/PCPAddTest.php @@ -33,27 +33,20 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { } function testPCPAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Log in using webtestLogin() method - $this->webtestLogin(); - // visit event search page - //give permissions to anonymous user $permission = array('edit-1-profile-listings-and-forms', 'edit-1-access-all-custom-data', 'edit-1-register-for-events', 'edit-1-make-online-contributions'); $this->changePermissions($permission); + // Log in as normal user + $this->webtestLogin(); + // set domain values $domainNameValue = 'civicrm organization '; - $firstName = 'Ma' . substr(sha1(rand()), 0, 4); - $lastName = 'An' . substr(sha1(rand()), 0, 7); - $middleName = 'Mid' . substr(sha1(rand()), 0, 7); - $email = substr(sha1(rand()), 0, 7) . '@example.org'; - $this->open($this->sboxPath . 'civicrm/admin/domain?action=update&reset=1'); - $this->waitForElementPresent('_qf_Domain_cancel-bottom'); + $firstName = 'Ma' . substr(sha1(rand()), 0, 4); + $lastName = 'An' . substr(sha1(rand()), 0, 7); + $middleName = 'Mid' . substr(sha1(rand()), 0, 7); + $email = substr(sha1(rand()), 0, 7) . '@example.org'; + $this->openCiviPage("admin/domain", "action=update&reset=1", '_qf_Domain_cancel-bottom'); $this->type('name', $domainNameValue); $this->type('email_name', $firstName); $this->type('email_address', $email); @@ -112,15 +105,15 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { //event add for contribute campaign type $campaignType = 'event'; - $firstName = 'Pa' . substr(sha1(rand()), 0, 4); - $lastName = 'Cn' . substr(sha1(rand()), 0, 7); - $middleName = 'PCid' . substr(sha1(rand()), 0, 7); - $email = substr(sha1(rand()), 0, 7) . '@example.org'; + $firstName = 'Pa' . substr(sha1(rand()), 0, 4); + $lastName = 'Cn' . substr(sha1(rand()), 0, 7); + $middleName = 'PCid' . substr(sha1(rand()), 0, 7); + $email = substr(sha1(rand()), 0, 7) . '@example.org'; $this->_testAddEventForPCP($processorName, $campaignType, NULL, $firstName, $lastName, $middleName, $email); } function _testAddEventForPCP($processorName, $campaignType, $contributionPageId = NULL, $firstName, $lastName, $middleName, $email) { - // Go directly to the URL of the screen that you will be testing (New Event). + $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -142,11 +135,8 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { } function _testAddEventInfo($eventTitle, $eventDescription) { - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - // Let's start filling the form with values. $this->select("event_type_id", "value=1"); // Attendee role s/b selected now. @@ -250,8 +240,7 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { // registering online if ($anonymous) { - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); } //participant registeration @@ -299,8 +288,7 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { $this->assertStringsPresent($thankStrings); //pcp creation via different user - $this->open($this->sboxPath . "civicrm/contribute/campaign?action=add&reset=1&pageId=" . $pageId . "&component=event"); - $this->waitForElementPresent("_qf_PCPAccount_next-bottom"); + $this->openCiviPage('contribute/campaign', "action=add&reset=1&pageId={$pageId}&component=event", "_qf_PCPAccount_next-bottom"); $cmsUserName = 'CmsUser' . substr(sha1(rand()), 0, 7); @@ -322,13 +310,11 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { //admin pcp approval //login to check contribution - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); - $this->open($this->sboxPath . "civicrm/admin/pcp?reset=1&page_type=event"); - $this->waitForElementPresent("_qf_PCP_refresh"); + $this->openCiviPage('admin/pcp', 'reset=1&page_type=event', "_qf_PCP_refresh"); $this->select('status_id', 'value=1'); $this->click("_qf_PCP_refresh"); $this->waitForElementPresent("_qf_PCP_refresh"); @@ -338,9 +324,7 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - // Wait for Login button to indicate we've logged out. - $this->waitForElementPresent('edit-submit'); + $this->webtestLogout(); $this->open($this->sboxPath . $pcpUrl); $this->waitForElementPresent("xpath=//div[@class='pcp-donate']/a"); @@ -363,8 +347,8 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { $contributionAmount = '250.00'; } - $firstNameDonar = 'Andrew' . substr(sha1(rand()), 0, 7); - $lastNameDonar = 'Roger' . substr(sha1(rand()), 0, 7); + $firstNameDonar = 'Andrew' . substr(sha1(rand()), 0, 7); + $lastNameDonar = 'Roger' . substr(sha1(rand()), 0, 7); $middleNameDonar = 'Nicholas' . substr(sha1(rand()), 0, 7); $this->type("{$emailElement}", $firstNameDonar . "@example.com"); @@ -390,9 +374,6 @@ class WebTest_Event_PCPAddTest extends CiviSeleniumTestCase { } //login to check contribution - $this->open($this->sboxPath); - - // Log in using webtestLogin() method $this->webtestLogin(); if ($campaignType == 'event') { diff --git a/tests/phpunit/WebTest/Event/ParticipantCountTest.php b/tests/phpunit/WebTest/Event/ParticipantCountTest.php index 05f4ab2110..91d4c7fed4 100644 --- a/tests/phpunit/WebTest/Event/ParticipantCountTest.php +++ b/tests/phpunit/WebTest/Event/ParticipantCountTest.php @@ -33,7 +33,6 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { } function testParticipantCountWithFeelevel() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -58,8 +57,7 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { $infoEvent = $this->_testAddEvent($paramsEvent); // logout to register for event. - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); // Register Participant 1 // visit event info page @@ -93,12 +91,10 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { $this->_testRegisterWithBillingInfo(); // login to check participant count - $this->open($this->sboxPath); $this->webtestLogin(); // Find Participant - $this->open($this->sboxPath . 'civicrm/event/search?reset=1'); - $this->waitForElementPresent('participant_fee_amount_low'); + $this->openCiviPage("event/search", "reset=1", 'participant_fee_amount_low'); $this->click("event_name"); $this->type("event_name", $eventTitle); $this->typeKeys("event_name", $eventTitle); @@ -112,7 +108,6 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { } function testParticipantCountWithPriceset() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -207,8 +202,7 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { $infoEvent = $this->_testAddEvent($paramsEvent); // logout to register for event. - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); $priceFieldOptionCounts = $participants = array(); @@ -279,12 +273,10 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { ); // login to check participant count - $this->open($this->sboxPath); $this->webtestLogin(); // Find Participant - $this->open($this->sboxPath . 'civicrm/event/search?reset=1'); - $this->waitForElementPresent('participant_fee_amount_low'); + $this->openCiviPage('event/search', 'reset=1', 'participant_fee_amount_low'); $this->click("event_name"); $this->type("event_name", $eventTitle); $this->typeKeys("event_name", $eventTitle); @@ -302,9 +294,7 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { } function _testAddSet($setTitle, $financialType = 'Event Fee') { - $this->open($this->sboxPath . 'civicrm/admin/price?reset=1&action=add'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent('_qf_Set_next-bottom'); + $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom'); // Enter Priceset fields (Title, Used For ...) $this->type('title', $setTitle); @@ -333,11 +323,8 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { } function _testAddEvent($params) { - $this->open($this->sboxPath . 'civicrm/event/add?reset=1&action=add'); + $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); - $this->waitForElementPresent('_qf_EventInfo_upload-bottom'); - - // Let's start filling the form with values. $this->select('event_type_id', "value={$params['event_type_id']}"); // Attendee role s/b selected now. @@ -401,7 +388,7 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { // verify event input on info page // start at Manage Events listing - $this->open($this->sboxPath . 'civicrm/event/manage?reset=1'); + $this->openCiviPage('event/manage', 'reset=1'); $this->click('link=' . $params['title']); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -436,8 +423,7 @@ class WebTest_Event_ParticipantCountTest extends CiviSeleniumTestCase { } function _testPricesetDetailsCustomSearch($eventParams, $participants, $priceFieldOptionCounts) { - $this->open($this->sboxPath . 'civicrm/contact/search/custom?csid=9&reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->openCiviPage('contact/search/custom', 'csid=9&reset=1'); $this->select('event_id', 'label=' . $eventParams['title']); $this->click('_qf_Custom_refresh-bottom'); diff --git a/tests/phpunit/WebTest/Event/ParticipantSearchTest.php b/tests/phpunit/WebTest/Event/ParticipantSearchTest.php index 14d5fb7c8f..c3b3709dd3 100644 --- a/tests/phpunit/WebTest/Event/ParticipantSearchTest.php +++ b/tests/phpunit/WebTest/Event/ParticipantSearchTest.php @@ -40,16 +40,6 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { } function testParticipantSearchForm() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // visit event search page @@ -74,7 +64,6 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { } function testParticipantSearchForce() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -88,7 +77,6 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { } function testParticipantSearchEmpty() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -112,7 +100,6 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { } function testParticipantSearchEventName() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -137,7 +124,6 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { } function testParticipantSearchEventDate() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -164,7 +150,6 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { } function testParticipantSearchEventDateAndType() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -197,7 +182,6 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { } function testParticipantSearchCustomField() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -227,7 +211,6 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { } function testParticipantSearchForceAndView() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -256,7 +239,6 @@ class WebTest_Event_ParticipantSearchTest extends CiviSeleniumTestCase { } function testParticipantSearchForceAndEdit() { - $this->open($this->sboxPath); $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php b/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php index 0d34b345c8..c979bc1660 100644 --- a/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php +++ b/tests/phpunit/WebTest/Event/PricesetMaxCountTest.php @@ -33,8 +33,6 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { } function testWithoutFieldCount() { - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -160,8 +158,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $infoEvent = $this->_testAddEvent($paramsEvent); // logout to register for event. - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); // Register Participant 1 // visit event info page @@ -231,8 +228,6 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { } function testWithFieldCount() { - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -365,8 +360,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $infoEvent = $this->_testAddEvent($paramsEvent); // logout to register for event. - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); // Register Participant 1 // visit event info page @@ -437,8 +431,6 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { } function testAdditionalParticipantWithoutFieldCount() { - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -565,9 +557,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $infoEvent = $this->_testAddEvent($paramsEvent); // logout to register for event. - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - + $this->webtestLogout(); // 1'st registration // Register Participant 1 @@ -725,8 +715,6 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { } function testAdditionalParticipantWithFieldCount() { - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -860,9 +848,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { $infoEvent = $this->_testAddEvent($paramsEvent); // logout to register for event. - $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - + $this->webtestLogout(); // 1'st registration // Register Participant 1 @@ -1020,9 +1006,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { } function _testAddSet($setTitle, $financialType = NULL) { - $this->open($this->sboxPath . 'civicrm/admin/price?reset=1&action=add'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent('_qf_Set_next-bottom'); + $this->openCiviPage('admin/price', 'reset=1&action=add', '_qf_Set_next-bottom'); // Enter Priceset fields (Title, Used For ...) $this->type('title', $setTitle); @@ -1124,11 +1108,8 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { } function _testAddEvent($params) { - $this->open($this->sboxPath . 'civicrm/event/add?reset=1&action=add'); - - $this->waitForElementPresent('_qf_EventInfo_upload-bottom'); + $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); - // Let's start filling the form with values. $this->select('event_type_id', "value={$params['event_type_id']}"); // Attendee role s/b selected now. @@ -1198,7 +1179,7 @@ class WebTest_Event_PricesetMaxCountTest extends CiviSeleniumTestCase { // verify event input on info page // start at Manage Events listing - $this->open($this->sboxPath . 'civicrm/event/manage?reset=1'); + $this->openCiviPage('event/manage', 'reset=1'); $this->click('link=' . $params['title']); $this->waitForPageToLoad($this->getTimeoutMsec()); diff --git a/tests/phpunit/WebTest/Event/TellAFriendTest.php b/tests/phpunit/WebTest/Event/TellAFriendTest.php index 88bf78492c..740755cd9d 100644 --- a/tests/phpunit/WebTest/Event/TellAFriendTest.php +++ b/tests/phpunit/WebTest/Event/TellAFriendTest.php @@ -33,15 +33,9 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase { } function testAddEvent() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); - // Go directly to the URL of the screen that you will be testing (New Event). $this->open($this->sboxPath . "civicrm/event/add?reset=1&action=add"); $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7); @@ -74,8 +68,7 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase { $this->changePermissions($permission); // register as an anonymous user - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForElementPresent('edit-submit'); + $this->webtestLogout(); $this->open($registerUrl); $this->waitForElementPresent('_qf_Register_upload-bottom'); @@ -115,44 +108,38 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent($thankYouMsg)); // Log in using webtestLogin() method - $this->open($this->sboxPath); $this->webtestLogin(); // get all friends contact id - $this->open($this->sboxPath . "civicrm/contact/search?reset=1"); - $this->waitForElementPresent('_qf_Basic_refresh '); + $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); $this->type('sort_name', $firstName1); $this->click('_qf_Basic_refresh '); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/contact/search?reset=1"); - $this->waitForElementPresent('_qf_Basic_refresh '); + $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); $this->type('sort_name', $firstName2); $this->click('_qf_Basic_refresh '); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/contact/search?reset=1"); - $this->waitForElementPresent('_qf_Basic_refresh '); + $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); $this->type('sort_name', $firstName3); $this->click('_qf_Basic_refresh '); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("xpath=//div[@class='crm-search-results']/table/tbody/tr/td[11]/span/a[text()='View']"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "civicrm/contact/search?reset=1"); - $this->waitForElementPresent('_qf_Basic_refresh '); + $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); $this->type('sort_name', $firstName); $this->click('_qf_Basic_refresh '); $this->waitForElementPresent('Print'); $this->assertTrue($this->isTextPresent('1 Contact')); // Verify Activity created - $this->open($this->sboxPath . "civicrm/activity/search?reset=1"); - $this->waitForElementPresent('_qf_Search_refresh'); + $this->openCiviPage("activity/search", "reset=1", '_qf_Search_refresh'); $this->type('sort_name', $firstName1); $this->click('_qf_Search_refresh'); $this->waitForElementPresent("_qf_Search_next_print"); @@ -179,11 +166,8 @@ class WebTest_Event_TellAFriendTest extends CiviSeleniumTestCase { } function _testAddEventInfo($eventTitle, $eventDescription) { - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. $this->waitForElementPresent("_qf_EventInfo_upload-bottom"); - // Let's start filling the form with values. $this->select("event_type_id", "value=1"); // Attendee role s/b selected now. diff --git a/tests/phpunit/WebTest/Export/ContactTest.php b/tests/phpunit/WebTest/Export/ContactTest.php index c16bf70fad..f8df1770c6 100644 --- a/tests/phpunit/WebTest/Export/ContactTest.php +++ b/tests/phpunit/WebTest/Export/ContactTest.php @@ -36,13 +36,6 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase { * Test Contact Export. */ function testContactExport() { - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Create new group @@ -155,13 +148,6 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase { } function testMergeHousehold() { - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Create new group @@ -342,4 +328,4 @@ class WebTest_Export_ContactTest extends ExportCiviSeleniumTestCase { // Is status message correct? $this->assertElementContainsText('crm-notification-container', "The Group '$groupName' has been saved."); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php b/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php index 90083be3f3..97c4da1108 100644 --- a/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php +++ b/tests/phpunit/WebTest/Financial/FinancialAccountTypeTest.php @@ -32,7 +32,6 @@ class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase { function testFinancialAccount() { // To Add Financial Account // class attributes. - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -160,4 +159,4 @@ class WebTest_Financial_FinancialAccountTypeTest extends CiviSeleniumTestCase { //delete financialtype $this->addeditFinancialType($financialType , 'Delete'); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php index f4f695368c..3886b2354a 100644 --- a/tests/phpunit/WebTest/Financial/FinancialBatchExport.php +++ b/tests/phpunit/WebTest/Financial/FinancialBatchExport.php @@ -39,10 +39,8 @@ class WebTest_Financial_FinancialBatchExport extends CiviSeleniumTestCase { $this->open($this->sboxPath); // Log in using webtestLogin() method - $this->webtestLogin(TRUE); - $this->open($this->sboxPath . 'civicrm/financial/batch?reset=1&action=add'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent('_qf_FinancialBatch_next-botttom'); + $this->webtestLogin('admin'); + $this->openCiviPage("financial/batch", "reset=1&action=add", '_qf_FinancialBatch_next-botttom'); $setTitle = 'Batch ' . substr(sha1(rand()), 0, 7) . date('Y-m-d'); $setDescription = 'Test Batch Creation'; $setPaymentInstrument = 'Credit Card'; diff --git a/tests/phpunit/WebTest/Generic/CheckActivityTest.php b/tests/phpunit/WebTest/Generic/CheckActivityTest.php index 537b8282e6..9dbab8923a 100644 --- a/tests/phpunit/WebTest/Generic/CheckActivityTest.php +++ b/tests/phpunit/WebTest/Generic/CheckActivityTest.php @@ -33,11 +33,6 @@ class WebTest_Generic_CheckActivityTest extends CiviSeleniumTestCase { } function testCheckDashboardElements() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Generic/CheckDashboardTest.php b/tests/phpunit/WebTest/Generic/CheckDashboardTest.php index a472c00d80..fb9e01f0e3 100644 --- a/tests/phpunit/WebTest/Generic/CheckDashboardTest.php +++ b/tests/phpunit/WebTest/Generic/CheckDashboardTest.php @@ -34,7 +34,6 @@ class WebTest_Generic_CheckDashboardTest extends CiviSeleniumTestCase { } function testCheckDashboardElements() { - $this->open($this->sboxPath); $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Generic/CheckFindTest.php b/tests/phpunit/WebTest/Generic/CheckFindTest.php index b6079be8a6..aac06455a9 100644 --- a/tests/phpunit/WebTest/Generic/CheckFindTest.php +++ b/tests/phpunit/WebTest/Generic/CheckFindTest.php @@ -33,12 +33,9 @@ class WebTest_Generic_CheckFindTest extends CiviSeleniumTestCase { } function testCheckDashboardElements() { - $this->open($this->sboxPath); $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing. - $this->open($this->sboxPath . "civicrm/contact/search?reset=1"); - $this->waitForElementPresent("_qf_Basic_refresh"); + $this->openCiviPage("contact/search", "reset=1", "_qf_Basic_refresh"); $this->click("//input[@name='_qf_Basic_refresh' and @value='Search']"); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertTrue($this->isElementPresent("search-status")); diff --git a/tests/phpunit/WebTest/Generic/GeneralClickAroundTest.php b/tests/phpunit/WebTest/Generic/GeneralClickAroundTest.php index 6dca528bfb..bc24d359d5 100644 --- a/tests/phpunit/WebTest/Generic/GeneralClickAroundTest.php +++ b/tests/phpunit/WebTest/Generic/GeneralClickAroundTest.php @@ -33,7 +33,6 @@ class WebTest_Generic_GeneralClickAroundTest extends CiviSeleniumTestCase { } function login() { - $this->open($this->sboxPath); $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->click("//a[contains(text(),'CiviCRM')]"); diff --git a/tests/phpunit/WebTest/Grant/ContactContextAddTest.php b/tests/phpunit/WebTest/Grant/ContactContextAddTest.php index 2b5ba9909b..ff426cab7e 100644 --- a/tests/phpunit/WebTest/Grant/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Grant/ContactContextAddTest.php @@ -34,7 +34,7 @@ class WebTest_Grant_ContactContextAddTest extends CiviSeleniumTestCase { function testContactContextAddTest() { // Log in as admin first to verify permissions for CiviGrant - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); // Enable CiviGrant module if necessary $this->enableComponents("CiviGrant"); @@ -43,10 +43,13 @@ class WebTest_Grant_ContactContextAddTest extends CiviSeleniumTestCase { $permission = array('edit-2-access-civigrant', 'edit-2-edit-grants', 'edit-2-delete-in-civigrant'); $this->changePermissions($permission); + // Log in as normal user + $this->webtestLogin(); + // create unique name - $name = substr(sha1(rand()), 0, 7); + $name = substr(sha1(rand()), 0, 7); $firstName = 'Grant' . $name; - $lastName = 'L' . $name; + $lastName = 'L' . $name; // create new contact $this->webtestAddContact($firstName, $lastName); @@ -68,7 +71,6 @@ class WebTest_Grant_ContactContextAddTest extends CiviSeleniumTestCase { // check contact name on Grant form $this->assertElementContainsText('page-title', "$firstName $lastName"); - // Let's start filling the form with values. // select grant Status $this->select('status_id', 'value=1'); diff --git a/tests/phpunit/WebTest/Grant/CustomFieldsetTest.php b/tests/phpunit/WebTest/Grant/CustomFieldsetTest.php index 369dee3736..e13a93db16 100644 --- a/tests/phpunit/WebTest/Grant/CustomFieldsetTest.php +++ b/tests/phpunit/WebTest/Grant/CustomFieldsetTest.php @@ -34,7 +34,7 @@ class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase { function testCustomFieldsetTest() { // Log in as admin first to verify permissions for CiviGrant - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); // Enable CiviGrant module if necessary $this->enableComponents("CiviGrant"); @@ -43,6 +43,9 @@ class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase { $permission = array('edit-2-access-civigrant', 'edit-2-edit-grants', 'edit-2-delete-in-civigrant'); $this->changePermissions($permission); + // Log in as normal user + $this->webtestLogin(); + // Create unique identifier for names $rand = substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Grant/StandaloneAddTest.php b/tests/phpunit/WebTest/Grant/StandaloneAddTest.php index fdc4692fd4..f7b3d6ff5f 100644 --- a/tests/phpunit/WebTest/Grant/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Grant/StandaloneAddTest.php @@ -38,7 +38,7 @@ class WebTest_Grant_StandaloneAddTest extends CiviSeleniumTestCase { function testStandaloneGrantAdd() { // Log in as admin first to verify permissions for CiviGrant - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); // Enable CiviGrant module if necessary $this->enableComponents("CiviGrant"); @@ -47,10 +47,10 @@ class WebTest_Grant_StandaloneAddTest extends CiviSeleniumTestCase { $permission = array('edit-2-access-civigrant', 'edit-2-edit-grants', 'edit-2-delete-in-civigrant'); $this->changePermissions($permission); - // Go directly to the URL of the screen that you will be testing (New Contribution-standalone). - $this->openCiviPage('grant/add', 'reset=1&context=standalone', '_qf_Grant_upload'); + // Log in as normal user + $this->webtestLogin(); - // Let's start filling the form with values. + $this->openCiviPage('grant/add', 'reset=1&context=standalone', '_qf_Grant_upload'); // create new contact using dialog $firstName = substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Import/ActivityTest.php b/tests/phpunit/WebTest/Import/ActivityTest.php index 124cedba03..48ca8121e3 100644 --- a/tests/phpunit/WebTest/Import/ActivityTest.php +++ b/tests/phpunit/WebTest/Import/ActivityTest.php @@ -33,7 +33,6 @@ class WebTest_Import_ActivityTest extends ImportCiviSeleniumTestCase { } function testActivityImport() { - $this->open($this->sboxPath); $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Import/AddressImportTest.php b/tests/phpunit/WebTest/Import/AddressImportTest.php index cc2e8d33e8..ba4378ef20 100644 --- a/tests/phpunit/WebTest/Import/AddressImportTest.php +++ b/tests/phpunit/WebTest/Import/AddressImportTest.php @@ -33,16 +33,6 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { } function testCustomAddressDataImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7); @@ -109,7 +99,7 @@ class WebTest_Import_AddressImportTest extends ImportCiviSeleniumTestCase { } function _addCustomData() { - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->openCiviPage('admin/custom/group', 'reset=1'); //add new custom data diff --git a/tests/phpunit/WebTest/Import/AddressParsingTest.php b/tests/phpunit/WebTest/Import/AddressParsingTest.php index 32ba01a412..d0adffab7c 100644 --- a/tests/phpunit/WebTest/Import/AddressParsingTest.php +++ b/tests/phpunit/WebTest/Import/AddressParsingTest.php @@ -37,11 +37,6 @@ class WebTest_Import_AddressParsingTest extends ImportCiviSeleniumTestCase { */ function testValidStreetAddressParsing() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Logging in. $this->webtestLogin(); @@ -99,7 +94,6 @@ class WebTest_Import_AddressParsingTest extends ImportCiviSeleniumTestCase { * Function to check for Invalid Street Address */ function testInvalidStreetAddressParsing() { - $this->open($this->sboxPath); // Logging in. $this->webtestLogin(); @@ -160,7 +154,6 @@ class WebTest_Import_AddressParsingTest extends ImportCiviSeleniumTestCase { * Function to check Street Address when Address Parsing is Disabled */ function testStreetAddress() { - $this->open($this->sboxPath); // Logging in. $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php index f32b63fc0c..2b0e919b54 100644 --- a/tests/phpunit/WebTest/Import/ContactCustomDataTest.php +++ b/tests/phpunit/WebTest/Import/ContactCustomDataTest.php @@ -33,16 +33,6 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase { } function testCustomDataImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7); @@ -140,7 +130,7 @@ class WebTest_Import_ContactCustomDataTest extends ImportCiviSeleniumTestCase { } function _addCustomData() { - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->open($this->sboxPath . "civicrm/admin/custom/group?reset=1"); //add new custom data diff --git a/tests/phpunit/WebTest/Import/ContactSubtypeTest.php b/tests/phpunit/WebTest/Import/ContactSubtypeTest.php index c8ce1eeb27..bdcd01608d 100644 --- a/tests/phpunit/WebTest/Import/ContactSubtypeTest.php +++ b/tests/phpunit/WebTest/Import/ContactSubtypeTest.php @@ -40,16 +40,6 @@ class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase { * Test contact import for Individuals Subtype. */ function testIndividualSubtypeImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get sample import data. @@ -135,16 +125,6 @@ class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase { * Test contact import for Organization Subtype. */ function testOrganizationSubtypeImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get sample import data. @@ -224,16 +204,6 @@ class WebTest_Import_ContactSubtypeTest extends ImportCiviSeleniumTestCase { * Test contact import for Household Subtype. */ function testHouseholdSubtypeImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Create Household Subtype diff --git a/tests/phpunit/WebTest/Import/ContactTest.php b/tests/phpunit/WebTest/Import/ContactTest.php index a7a29849d6..d38bfcc15c 100644 --- a/tests/phpunit/WebTest/Import/ContactTest.php +++ b/tests/phpunit/WebTest/Import/ContactTest.php @@ -40,17 +40,6 @@ class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase { * Test contact import for Individuals. */ function testIndividualImport() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get sample import data. @@ -140,7 +129,6 @@ class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase { * Test contact import for Organization. */ function testOrganizationImport() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -224,7 +212,6 @@ class WebTest_Import_ContactTest extends ImportCiviSeleniumTestCase { * Test contact import for Household. */ function testHouseholdImport() { - $this->open($this->sboxPath); $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Import/ContributionTest.php b/tests/phpunit/WebTest/Import/ContributionTest.php index d19ac51ad9..d8e6cd9803 100644 --- a/tests/phpunit/WebTest/Import/ContributionTest.php +++ b/tests/phpunit/WebTest/Import/ContributionTest.php @@ -33,7 +33,6 @@ class WebTest_Import_ContributionTest extends ImportCiviSeleniumTestCase { } function testContributionImportIndividual() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -50,7 +49,6 @@ class WebTest_Import_ContributionTest extends ImportCiviSeleniumTestCase { } function testContributionImportOrganization() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -65,7 +63,6 @@ class WebTest_Import_ContributionTest extends ImportCiviSeleniumTestCase { } function testContributionImportHousehold() { - $this->open($this->sboxPath); $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Import/CustomDataTest.php b/tests/phpunit/WebTest/Import/CustomDataTest.php index d2acbd67cb..9759c6e26e 100644 --- a/tests/phpunit/WebTest/Import/CustomDataTest.php +++ b/tests/phpunit/WebTest/Import/CustomDataTest.php @@ -33,16 +33,6 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { } function testCustomDataImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7); @@ -78,8 +68,7 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { $this->importContacts($headers, $rows, 'Individual', 'Skip', array(), $other); // Find the contact - $this->open($this->sboxPath . "civicrm/contact/search?reset=1"); - $this->waitForElementPresent('_qf_Basic_refresh'); + $this->openCiviPage("contact/search", "reset=1", '_qf_Basic_refresh'); $this->type('sort_name', $firstName1); $this->click('_qf_Basic_refresh'); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -153,7 +142,7 @@ class WebTest_Import_CustomDataTest extends ImportCiviSeleniumTestCase { } function _addCustomData($customGroupTitle, $id1, $id2) { - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->open($this->sboxPath . "civicrm/admin/custom/group?reset=1"); //add new custom data diff --git a/tests/phpunit/WebTest/Import/DateFormatTest.php b/tests/phpunit/WebTest/Import/DateFormatTest.php index 574cc1126b..55729ebfa9 100644 --- a/tests/phpunit/WebTest/Import/DateFormatTest.php +++ b/tests/phpunit/WebTest/Import/DateFormatTest.php @@ -40,16 +40,6 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { * Test contact import for yyyy_mm_dd date format. */ function testDateFormat_yyyy_mm_dd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get sample import data. @@ -65,16 +55,6 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { * Test contact import for mm_dd_yy date format. */ function testDateFormat_mm_dd_yy() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get sample import data. @@ -91,11 +71,6 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { * Test contact import for mm_dd_yyyy date format. */ function testDateFormat_mm_dd_yyyy() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Logging in. Remember to wait for page to load. In most cases, // you can rely on 30000 as the value that allows your test to pass, however, // sometimes your test might fail because of this. In such cases, it's better to pick one element @@ -117,11 +92,6 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { * Test contact import for Month_dd_yyyy date format. */ function testDateFormat_Month_dd_yyyy() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Logging in. Remember to wait for page to load. In most cases, // you can rely on 30000 as the value that allows your test to pass, however, // sometimes your test might fail because of this. In such cases, it's better to pick one element @@ -143,11 +113,6 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { * Test contact import for dd_mon_yy date format. */ function testDateFormat_dd_mon_yy() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Logging in. Remember to wait for page to load. In most cases, // you can rely on 30000 as the value that allows your test to pass, however, // sometimes your test might fail because of this. In such cases, it's better to pick one element @@ -169,11 +134,6 @@ class WebTest_Import_DateFormatTest extends ImportCiviSeleniumTestCase { * Test contact import for dd_mm_yyyy date format. */ function testDateFormat_dd_mm_yyyy() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Logging in. Remember to wait for page to load. In most cases, // you can rely on 30000 as the value that allows your test to pass, however, // sometimes your test might fail because of this. In such cases, it's better to pick one element diff --git a/tests/phpunit/WebTest/Import/DuplicateMatchingTest.php b/tests/phpunit/WebTest/Import/DuplicateMatchingTest.php index b76c18e40d..025a133b19 100644 --- a/tests/phpunit/WebTest/Import/DuplicateMatchingTest.php +++ b/tests/phpunit/WebTest/Import/DuplicateMatchingTest.php @@ -36,21 +36,9 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase { * Test contact import for Individuals Duplicate Matching. */ function testIndividualDuplicateMatchingImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of New Individual. - $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Individual'); - $this->waitForElementPresent('first_name'); + $this->openCiviPage("contact/add", "reset=1&ct=Individual", 'first_name'); $email = substr(sha1(rand()), 0, 7) . '@example.com'; @@ -150,21 +138,10 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase { * Test contact import for Organization Duplicate Matching. */ function testOrganizationDuplicateMatchingImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); //create oranization - $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Organization'); - $this->waitForElementPresent('organization_name'); + $this->openCiviPage("contact/add", "reset=1&ct=Organization", 'organization_name'); // get value for organization contact $organizationName = 'org_' . substr(sha1(rand()), 0, 7); @@ -258,21 +235,10 @@ class WebTest_Import_DuplicateMatchingTest extends ImportCiviSeleniumTestCase { * Test contact import for Household Duplicate Matching. */ function testHouseholdDuplicateMatchingImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // create household - $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Household'); - $this->waitForElementPresent('household_name'); + $this->openCiviPage("contact/add", "reset=1&ct=Household", 'household_name'); // get values for household contact $householdName = 'household_' . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Import/GroupTest.php b/tests/phpunit/WebTest/Import/GroupTest.php index 9d14fce14f..694f02597d 100644 --- a/tests/phpunit/WebTest/Import/GroupTest.php +++ b/tests/phpunit/WebTest/Import/GroupTest.php @@ -39,17 +39,6 @@ class WebTest_Import_GroupTest extends ImportCiviSeleniumTestCase { * Test contact import for Individuals. */ function testIndividualImportWithGroup() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get sample import data. diff --git a/tests/phpunit/WebTest/Import/MatchExternalIdTest.php b/tests/phpunit/WebTest/Import/MatchExternalIdTest.php index 2fbb6ccf50..d4b636aebf 100644 --- a/tests/phpunit/WebTest/Import/MatchExternalIdTest.php +++ b/tests/phpunit/WebTest/Import/MatchExternalIdTest.php @@ -36,11 +36,6 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { * Test participant import for Individuals matching on external identifier. */ function testContributionImport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - $this->webtestLogin(); // Get sample import data. @@ -54,11 +49,6 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { * Test membership import for Individuals matching on external identifier. */ function testMemberImportIndividual() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - $this->webtestLogin(); // Get membership import data for Individuals. @@ -72,11 +62,6 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { * Test participant import for Individuals matching on external identifier. */ function testParticipantImportIndividual() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -296,7 +281,6 @@ class WebTest_Import_MatchExternalIdTest extends ImportCiviSeleniumTestCase { $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); - // Let's start filling the form with values. $this->select("event_type_id", "value={$params['event_type_id']}"); // Attendee role s/b selected now. diff --git a/tests/phpunit/WebTest/Import/MemberTest.php b/tests/phpunit/WebTest/Import/MemberTest.php index ef7555c4b1..61fb200ff5 100644 --- a/tests/phpunit/WebTest/Import/MemberTest.php +++ b/tests/phpunit/WebTest/Import/MemberTest.php @@ -36,7 +36,6 @@ class WebTest_Import_MemberTest extends ImportCiviSeleniumTestCase { * Test participant import for Individuals. */ function testMemberImportIndividual() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -51,7 +50,6 @@ class WebTest_Import_MemberTest extends ImportCiviSeleniumTestCase { * Test participant import for Households. */ function testMemberImportHousehold() { - $this->open($this->sboxPath); $this->webtestLogin(); @@ -66,7 +64,6 @@ class WebTest_Import_MemberTest extends ImportCiviSeleniumTestCase { * Test participant import for Organizations. */ function testMemberImportOrganization() { - $this->open($this->sboxPath); $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Import/MultipleRelationshipTest.php b/tests/phpunit/WebTest/Import/MultipleRelationshipTest.php index a27c2108cf..efd884947c 100644 --- a/tests/phpunit/WebTest/Import/MultipleRelationshipTest.php +++ b/tests/phpunit/WebTest/Import/MultipleRelationshipTest.php @@ -40,17 +40,6 @@ class WebTest_Import_MultipleRelationshipTest extends ImportCiviSeleniumTestCase * Test Multiple Relationship import for Individuals. */ function testMultipleRelationshipImport() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get sample import data. diff --git a/tests/phpunit/WebTest/Import/ParticipantTest.php b/tests/phpunit/WebTest/Import/ParticipantTest.php index a3d144fa5b..d330e9ddec 100644 --- a/tests/phpunit/WebTest/Import/ParticipantTest.php +++ b/tests/phpunit/WebTest/Import/ParticipantTest.php @@ -36,11 +36,6 @@ class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase { * Test participant import for Individuals. */ function testParticipantImportIndividual() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -62,11 +57,6 @@ class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase { * Test participant import for Organizations. */ function testParticipantImportOrganization() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -88,11 +78,6 @@ class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase { * Test participant import for Households. */ function testParticipantImportHousehold() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -273,7 +258,6 @@ class WebTest_Import_ParticipantTest extends ImportCiviSeleniumTestCase { $this->openCiviPage('event/add', 'reset=1&action=add', '_qf_EventInfo_upload-bottom'); - // Let's start filling the form with values. $this->select("event_type_id", "value={$params['event_type_id']}"); // Attendee role s/b selected now. diff --git a/tests/phpunit/WebTest/Import/SavedMappingTest.php b/tests/phpunit/WebTest/Import/SavedMappingTest.php index 9c671265f4..063ce78d3f 100644 --- a/tests/phpunit/WebTest/Import/SavedMappingTest.php +++ b/tests/phpunit/WebTest/Import/SavedMappingTest.php @@ -41,11 +41,6 @@ class WebTest_Import_SavedMapping extends ImportCiviSeleniumTestCase { */ function testSaveIndividualMapping() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Logging in. $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Import/TagTest.php b/tests/phpunit/WebTest/Import/TagTest.php index c620f38c5e..95ff4b7910 100644 --- a/tests/phpunit/WebTest/Import/TagTest.php +++ b/tests/phpunit/WebTest/Import/TagTest.php @@ -37,17 +37,6 @@ class WebTest_Import_TagTest extends ImportCiviSeleniumTestCase { * Test contact import for Individuals. */ function testContactImportWithTag() { - - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // Get sample import data. diff --git a/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php b/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php index 5a2d5d07c4..0189f84598 100644 --- a/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php +++ b/tests/phpunit/WebTest/Mailing/AddMessageTemplateTest.php @@ -35,7 +35,6 @@ class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase { function testTemplateAdd($useTokens = FALSE, $msgTitle = NULL) { $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (Add Message Template). $this->openCiviPage("admin/messageTemplates/add", "action=add&reset=1"); // Fill message title. @@ -120,7 +119,6 @@ class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase { $this->click('_qf_MailSettings_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to Schedule and Send Mailing form $this->openCiviPage("mailing/send", "reset=1", "_qf_Group_cancel"); // fill mailing name @@ -194,4 +192,4 @@ class WebTest_Mailing_AddMessageTemplateTest extends CiviSeleniumTestCase { $this->waitForElementPresent("_qf_ActivityView_next"); $this->assertElementContainsText('help', "Bulk Email Sent.", "Status message didn't show up after saving!"); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Mailing/AddNewMailingComponentTest.php b/tests/phpunit/WebTest/Mailing/AddNewMailingComponentTest.php index ebf4e6ee36..fc1f545a9b 100644 --- a/tests/phpunit/WebTest/Mailing/AddNewMailingComponentTest.php +++ b/tests/phpunit/WebTest/Mailing/AddNewMailingComponentTest.php @@ -33,19 +33,8 @@ class WebTest_Mailing_AddNewMailingComponentTest extends CiviSeleniumTestCase { } function testHeaderAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (Add New Mailing Component). $this->openCiviPage("admin/component", "action=add&reset=1"); // fill component name. @@ -81,14 +70,8 @@ class WebTest_Mailing_AddNewMailingComponentTest extends CiviSeleniumTestCase { } function testFooterAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (Add New Mailing Component). $this->openCiviPage("admin/component", "action=add&reset=1"); // fill component name. @@ -124,14 +107,8 @@ class WebTest_Mailing_AddNewMailingComponentTest extends CiviSeleniumTestCase { } function testAutomatedAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (Add New Mailing Component). $this->openCiviPage("admin/component", "action=add&reset=1"); // fill component name. @@ -165,4 +142,4 @@ class WebTest_Mailing_AddNewMailingComponentTest extends CiviSeleniumTestCase { // Verify text $this->assertTrue($this->isElementPresent("xpath=//table/tbody//tr/td[text()='{$componentName}']/../td[2][text()='Reply']/../td[3][text()='{$subject}']/../td[4][text()='{$txtMsg}']/../td[5][text()='{$htmlMsg}']"), "The row doesn't consists of proper component details"); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Mailing/MailingTest.php b/tests/phpunit/WebTest/Mailing/MailingTest.php index 11731f6957..3151fbb53a 100644 --- a/tests/phpunit/WebTest/Mailing/MailingTest.php +++ b/tests/phpunit/WebTest/Mailing/MailingTest.php @@ -33,12 +33,10 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { } function testAddMailing() { - $this->open($this->sboxPath); $this->webtestLogin(); //----do create test mailing group - // Go directly to the URL of the screen that you will be testing (New Group). $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload"); // make group name @@ -88,7 +86,6 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->click('_qf_MailSettings_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to Schedule and Send Mailing form $this->openCiviPage("mailing/send", "reset=1", "_qf_Group_cancel"); //-------select recipients---------- @@ -239,14 +236,13 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { // verify email $this->verifyText("xpath=//table[@id='mailing_event']/tbody//tr/td[2]", preg_quote("mailino$firstName@mailson.co.in")); - require_once 'CRM/Mailing/Event/DAO/Queue.php'; $eventQueue = new CRM_Mailing_Event_DAO_Queue(); $eventQueue->contact_id = $contactId; $eventQueue->find(TRUE); $permission = array('edit-1-access-civimail-subscribeunsubscribe-pages'); $this->changePermissions($permission); - $this->openCiviPage('logout', 'reset=1', NULL); + $this->webtestLogout(); // build forward url $forwardUrl = array("mailing/forward", "reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}"); @@ -262,7 +258,6 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertElementContainsText('css=div.messages', 'Mailing is forwarded successfully to 2 email addresses'); - $this->open($this->sboxPath); $this->waitForPageToLoad($this->getTimeoutMsec()); $this->webtestLogin(); @@ -290,8 +285,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { // $unsubscribeUrl = "civicrm/mailing/optout?reset=1&jid={$eventQueue->job_id}&qid={$eventQueue->id}&h={$eventQueue->hash}&confirm=1"; // // logout to unsubscribe - // $this->open($this->sboxPath . 'civicrm/logout?reset=1'); - // $this->waitForPageToLoad($this->getTimeoutMsec()); + // $this->webtestLogout(); // // click(visit) unsubscribe path // $this->open($this->sboxPath . $unsubscribeUrl); @@ -313,10 +307,8 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { function testAdvanceSearchAndReportCheck() { - $this->open($this->sboxPath); $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Group). $this->openCiviPage("group/add", "reset=1", "_qf_Edit_upload"); // make group name @@ -366,7 +358,7 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { $this->click('_qf_MailSettings_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - // Go directly to Schedule and Send Mailing form + // Go to Schedule and Send Mailing form $this->openCiviPage('mailing/send', 'reset=1', '_qf_Group_cancel'); //-------select recipients---------- @@ -563,4 +555,4 @@ class WebTest_Mailing_MailingTest extends CiviSeleniumTestCase { } } } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Mailing/SpoolTest.php b/tests/phpunit/WebTest/Mailing/SpoolTest.php index 8d17025dfd..5e5aeafb3e 100644 --- a/tests/phpunit/WebTest/Mailing/SpoolTest.php +++ b/tests/phpunit/WebTest/Mailing/SpoolTest.php @@ -37,7 +37,6 @@ class WebTest_Mailing_SpoolTest extends CiviSeleniumTestCase { function testSpooledMailing() { - $this->open($this->sboxPath); $this->webtestLogin(); // Start spooling mail diff --git a/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php b/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php index d47791efa3..337c86909a 100644 --- a/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php +++ b/tests/phpunit/WebTest/Member/BatchUpdateViaProfileTest.php @@ -33,11 +33,6 @@ class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase { } function testMemberAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -189,7 +184,7 @@ class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase { } function _addProfile($profileTitle, $customDataParams) { - // Go directly to the URL of the screen that you will be testing (New Profile). + $this->openCiviPage("admin/uf/group", "reset=1"); $this->click('link=Add Profile'); @@ -224,7 +219,7 @@ class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase { function _addCustomData() { $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4); - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->openCiviPage('admin/custom/group', 'reset=1'); //add new custom data @@ -266,4 +261,4 @@ class WebTest_Member_BatchUpdateViaProfileTest extends CiviSeleniumTestCase { return array($textFieldLabel, $customGroupTitle); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Member/ContactContextAddTest.php b/tests/phpunit/WebTest/Member/ContactContextAddTest.php index dea47e79ba..609648c045 100644 --- a/tests/phpunit/WebTest/Member/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Member/ContactContextAddTest.php @@ -33,14 +33,12 @@ class WebTest_Member_ContactContextAddTest extends CiviSeleniumTestCase { } function testContactMemberAdd() { - $this->open($this->sboxPath); $this->webtestLogin(); // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership) $memTypeParams = $this->webtestAddMembershipType(); $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime'); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->openCiviPage("contact/add", "reset=1&ct=Individual"); $firstName = "John_" . substr(sha1(rand()), 0, 7); @@ -160,13 +158,11 @@ class WebTest_Member_ContactContextAddTest extends CiviSeleniumTestCase { } function testMemberAddWithLifeTimeMembershipType() { - $this->open($this->sboxPath); $this->webtestLogin(); // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership) $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime'); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->openCiviPage("contact/add", "reset=1&ct=Individual"); $firstName = "John_" . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php b/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php index 0dbf1d4a41..801d787946 100755 --- a/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php +++ b/tests/phpunit/WebTest/Member/DefaultMembershipPricesetTest.php @@ -33,11 +33,6 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase } function testDefaultPricesetSelection() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -84,8 +79,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase $this->assertType('numeric', $cid); //senario 1 - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id={$membershipContributionPageId}&cid={$cid}"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id={$membershipContributionPageId}&cid={$cid}", "_qf_Main_upload-bottom"); $this->_testDefaultSenarios("National_Membership_{$title}-section", 2); $this->contactInfoFill($firstName, $lastName, $email, $contactParams, $streetAddress); @@ -96,8 +90,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase $this->waitForPageToLoad($this->getTimeoutMsec()); //senario 2 - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id={$membershipContributionPageId}&cid={$cid}"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id={$membershipContributionPageId}&cid={$cid}", "_qf_Main_upload-bottom"); // checking $this->checkOptions("National_Membership_{$title}-section", 2); // senario 1 @@ -111,8 +104,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase $this->waitForPageToLoad($this->getTimeoutMsec()); //senario 3 - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id={$membershipContributionPageId}&cid={$cid}"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id={$membershipContributionPageId}&cid={$cid}", "_qf_Main_upload-bottom"); // checking $this->checkOptions("Second_Membership_{$title}-section", 2); // senario 2 @@ -126,8 +118,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase $this->waitForPageToLoad($this->getTimeoutMsec()); //senario 4 - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id={$membershipContributionPageId}&cid={$cid}"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id={$membershipContributionPageId}&cid={$cid}", "_qf_Main_upload-bottom"); // checking senario 3 $this->assertTrue($this->isTextPresent("You have a current Lifetime Membership which does not need to be renewed.")); @@ -166,9 +157,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase } function _testAddSet($setTitle, $usedFor, $contributionType = NULL, $setHelp) { - $this->open($this->sboxPath . 'civicrm/admin/price?reset=1&action=add'); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent('_qf_Set_next-bottom'); + $this->openCiviPage("admin/price", "reset=1&action=add", '_qf_Set_next-bottom'); // Enter Priceset fields (Title, Used For ...) $this->type('title', $setTitle); @@ -180,7 +169,7 @@ class WebTest_Member_DefaultMembershipPricesetTest extends CiviSeleniumTestCase } elseif ($usedFor == 'Membership') { $this->click('extends[3]'); - $this->waitForElementPresent( 'financial_type_id' ); + $this->waitForElementPresent( 'financial_type_id' ); $this->select("css=select.form-select", "label={$contributionType}"); } diff --git a/tests/phpunit/WebTest/Member/EditMembershipTest.php b/tests/phpunit/WebTest/Member/EditMembershipTest.php index 16cef0586a..05e8ffcb06 100644 --- a/tests/phpunit/WebTest/Member/EditMembershipTest.php +++ b/tests/phpunit/WebTest/Member/EditMembershipTest.php @@ -31,7 +31,6 @@ class WebTest_Member_EditMembershipTest extends CiviSeleniumTestCase { } function testEditMembershipActivityTypes() { - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); // create contact @@ -100,4 +99,4 @@ class WebTest_Member_EditMembershipTest extends CiviSeleniumTestCase { $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[3][text()='Type changed from {$membershipTypes['membership_type']} to General']")); $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[5]/a[text()='{$contactName}']")); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php b/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php index a40fdd0ae3..3ce04398b2 100644 --- a/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php +++ b/tests/phpunit/WebTest/Member/FixedMembershipTypeTest.php @@ -38,16 +38,10 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase { // Join Date > Rollover Date and Join Date < Start Date - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); - $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Organization"); - $this->waitForElementPresent('_qf_Contact_cancel'); + $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel'); $title = substr(sha1(rand()), 0, 7); $this->type('organization_name', "Organization $title"); @@ -57,7 +51,6 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent("Organization $title has been created.")); - // Go directly to the URL $this->open($this->sboxPath . "civicrm/admin/member/membershipType?reset=1&action=browse"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -89,7 +82,6 @@ class WebTest_Member_FixedMembershipTypeTest extends CiviSeleniumTestCase { $this->waitForElementPresent('link=Add Membership Type'); $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved.")); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); $firstName = "John_" . substr(sha1(rand()), 0, 7); @@ -204,16 +196,10 @@ SELECT end_event_adjust_interval // Rollover Date < Join Date - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); - $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Organization"); - $this->waitForElementPresent('_qf_Contact_cancel'); + $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel'); $title = substr(sha1(rand()), 0, 7); $this->type('organization_name', "Organization $title"); @@ -223,7 +209,6 @@ SELECT end_event_adjust_interval $this->assertTrue($this->isTextPresent("Organization $title has been created.")); - // Go directly to the URL $this->open($this->sboxPath . "civicrm/admin/member/membershipType?reset=1&action=browse"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -255,7 +240,6 @@ SELECT end_event_adjust_interval $this->waitForElementPresent('link=Add Membership Type'); $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved.")); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); $firstName = "John_" . substr(sha1(rand()), 0, 7); @@ -372,16 +356,10 @@ SELECT end_event_adjust_interval // Join Date is later than Rollover Date - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); - $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Organization"); - $this->waitForElementPresent('_qf_Contact_cancel'); + $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel'); $title = substr(sha1(rand()), 0, 7); $this->type('organization_name', "Organization $title"); @@ -391,7 +369,6 @@ SELECT end_event_adjust_interval $this->assertTrue($this->isTextPresent("Organization $title has been created.")); - // Go directly to the URL $this->open($this->sboxPath . "civicrm/admin/member/membershipType?reset=1&action=browse"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -421,7 +398,6 @@ SELECT end_event_adjust_interval $this->waitForElementPresent('link=Add Membership Type'); $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved.")); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); $firstName = "John_" . substr(sha1(rand()), 0, 7); @@ -533,16 +509,10 @@ SELECT end_event_adjust_interval // Join Date is earlier than Rollover Date - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); - $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Organization"); - $this->waitForElementPresent('_qf_Contact_cancel'); + $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel'); $title = substr(sha1(rand()), 0, 7); $this->type('organization_name', "Organization $title"); @@ -552,7 +522,6 @@ SELECT end_event_adjust_interval $this->assertTrue($this->isTextPresent("Organization $title has been created.")); - // Go directly to the URL $this->open($this->sboxPath . "civicrm/admin/member/membershipType?reset=1&action=browse"); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -583,7 +552,6 @@ SELECT end_event_adjust_interval $this->waitForElementPresent('link=Add Membership Type'); $this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved.")); - // Go directly to the URL of the screen that you will be testing (New Individual). $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual"); $firstName = "John_" . substr(sha1(rand()), 0, 7); diff --git a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php index 28c573c762..4b873f8875 100644 --- a/tests/phpunit/WebTest/Member/InheritedMembershipTest.php +++ b/tests/phpunit/WebTest/Member/InheritedMembershipTest.php @@ -31,11 +31,6 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { } function testInheritedMembership() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -48,7 +43,6 @@ class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); $this->assertElementContainsText('crm-notification-container', "Organization {$title} has been created."); - // Go directly to the URL $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); $this->click('link=Add Membership Type'); diff --git a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php index 0782b3bf6a..3a7210e633 100644 --- a/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OfflineAutoRenewMembershipTest.php @@ -33,7 +33,6 @@ class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase } function testOfflineAutoRenewMembership() { - $this->open($this->sboxPath); $this->webtestLogin(); // We need a payment processor @@ -94,8 +93,7 @@ class WebTest_Member_OfflineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->waitForPageToLoad($this->getTimeoutMsec()); // Use Find Members to make sure membership exists - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForElementPresent("member_end_date_high"); + $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); $this->type("sort_name", "$firstName $lastName"); $this->click("member_test"); diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php index 4498de2d49..d4ab55bea5 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipAddPricesetTest.php @@ -33,11 +33,6 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa } function testAddPriceSet() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -84,11 +79,6 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa } function testAddPriceSetWithMultipleTerms() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -294,7 +284,7 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa } if (!$renew) { - // Go directly to the URL of the screen that you will be testing (Activity Tab). + $this->click('css=li#tab_member a'); $this->waitForElementPresent('link=Add Membership'); @@ -371,7 +361,6 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } - // Go directly to the URL of the screen that you will be testing (Activity Tab). $this->click('css=li#tab_member a'); $this->waitForElementPresent('link=Add Membership'); @@ -407,4 +396,4 @@ class WebTest_Member_OfflineMembershipAddPricesetTest extends CiviSeleniumTestCa $this->click("_qf_MembershipView_cancel-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php index 30cdc36403..6905923ae1 100644 --- a/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php +++ b/tests/phpunit/WebTest/Member/OfflineMembershipRenewTest.php @@ -33,7 +33,6 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { } function testOfflineMembershipRenew() { - $this->open($this->sboxPath); $this->webtestLogin(); // make sure period is correct for the membership type we testing for, @@ -120,7 +119,6 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { } function testOfflineMemberRenewOverride() { - $this->open($this->sboxPath); $this->webtestLogin(); // add membership type @@ -229,7 +227,6 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { } function testOfflineMembershipRenewChangeType() { - $this->open($this->sboxPath); $this->webtestLogin(); // make sure period is correct for the membership type we testing for, @@ -326,7 +323,6 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { } function testOfflineMembershipRenewMultipleTerms() { - $this->open($this->sboxPath); $this->webtestLogin(); // make sure period is correct for the membership type we testing for, @@ -442,4 +438,4 @@ class WebTest_Member_OfflineMembershipRenewTest extends CiviSeleniumTestCase { ); $this->webtestVerifyTabularData($verifyMembershipRenewData); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php index a59277a108..52fc5a2939 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipGCTest.php @@ -64,7 +64,6 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas //configure membership signup page. $pageId = $this->_configureMembershipPage(); - $this->open($this->sboxPath); $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -96,12 +95,11 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas static $pageId = NULL; if (!$pageId) { - $this->open($this->sboxPath); $this->webtestLogin(); //add payment processor. - $hash = substr(sha1(rand()), 0, 7); - $rand = 2 * rand(2, 50); + $hash = substr(sha1(rand()), 0, 7); + $rand = 2 * rand(2, 50); $processorName = "Webtest Auto Renew Google Checkout" . $hash; $this->webtestAddPaymentProcessor($processorName, 'Google_Checkout'); @@ -135,21 +133,21 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas $this->waitForPageToLoad($this->getTimeoutMsec()); // create contribution page with randomized title and default params - $amountSection = FALSE; - $payLater = TRUE; - $onBehalf = FALSE; - $pledges = FALSE; - $recurring = TRUE; + $amountSection = FALSE; + $payLater = TRUE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = TRUE; $membershipTypes = array(array('id' => 1, 'auto_renew' => 1), array('id' => 2, 'auto_renew' => 1), ); $memPriceSetId = NULL; - $friend = TRUE; - $profilePreId = NULL; + $friend = TRUE; + $profilePreId = NULL; $profilePostId = NULL; - $premiums = TRUE; - $widget = TRUE; - $pcp = TRUE; + $premiums = TRUE; + $widget = TRUE; + $pcp = TRUE; $contributionTitle = "Title $hash"; $pageId = $this->webtestAddContributionPage($hash, @@ -172,15 +170,12 @@ class WebTest_Member_OnlineAutoRenewMembershipGCTest extends CiviSeleniumTestCas FALSE ); - // now logout and login with admin credentials - $this->openCiviPage('logout', 'reset=1', NULL); - //make sure we do have required permissions. $permissions = array("edit-1-make-online-contributions"); $this->changePermissions($permissions); // now logout and do membership test that way - $this->openCiviPage('logout', 'reset=1', NULL); + $this->webtestLogout(); } return $pageId; diff --git a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php index 86cef37290..528540b774 100644 --- a/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php +++ b/tests/phpunit/WebTest/Member/OnlineAutoRenewMembershipTest.php @@ -67,7 +67,6 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase //configure membership signup page. $pageId = $this->_configureMembershipPage(); - $this->open($this->sboxPath); $this->webtestLogin(); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -129,12 +128,11 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase static $pageId = NULL; if (!$pageId) { - $this->open($this->sboxPath); - $this->webtestLogin(); + $this->webtestLogin(); //add payment processor. - $hash = substr(sha1(rand()), 0, 7); - $rand = 2 * rand(2, 50); + $hash = substr(sha1(rand()), 0, 7); + $rand = 2 * rand(2, 50); $processorName = "Webtest Auto Renew AuthNet" . $hash; $this->webtestAddPaymentProcessor($processorName, 'AuthNet'); @@ -167,21 +165,21 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase // create contribution page with randomized title and default params - $amountSection = FALSE; - $payLater = TRUE; - $onBehalf = FALSE; - $pledges = FALSE; - $recurring = TRUE; + $amountSection = FALSE; + $payLater = TRUE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = TRUE; $membershipTypes = array(array('id' => 1, 'auto_renew' => 1), array('id' => 2, 'auto_renew' => 1), ); $memPriceSetId = NULL; - $friend = TRUE; - $profilePreId = NULL; + $friend = TRUE; + $profilePreId = NULL; $profilePostId = NULL; - $premiums = TRUE; - $widget = TRUE; - $pcp = TRUE; + $premiums = TRUE; + $widget = TRUE; + $pcp = TRUE; $contributionTitle = "Title $hash"; $pageId = $this->webtestAddContributionPage($hash, @@ -209,7 +207,7 @@ class WebTest_Member_OnlineAutoRenewMembershipTest extends CiviSeleniumTestCase $this->changePermissions($permissions); // now logout and do membership test that way - $this->openCiviPage('logout', 'reset=1', NULL); + $this->webtestLogout(); } return $pageId; diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php index 3d6421ac0b..f5dea7d92e 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipAddPricesetTest.php @@ -33,24 +33,18 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas } function testAddPriceSet() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Log in using webtestLogin() method - $this->webtestLogin(); - - // add the required Drupal permission - + // add the required permission $permissions = array('edit-1-make-online-contributions'); $this->changePermissions($permissions); - $title = substr(sha1(rand()), 0, 7); - $setTitle = "Membership Fees - $title"; - $usedFor = 'Membership'; + // Log in as normal user + $this->webtestLogin(); + + $title = substr(sha1(rand()), 0, 7); + $setTitle = "Membership Fees - $title"; + $usedFor = 'Membership'; $contributionType = 'Donation'; - $setHelp = 'Select your membership options.'; + $setHelp = 'Select your membership options.'; $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -80,8 +74,8 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); $firstName = 'John_' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); - $email = "{$firstName}.{$lastName}@example.com"; + $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); + $email = "{$firstName}.{$lastName}@example.com"; $contactParams = array( 'first_name' => $firstName, @@ -95,28 +89,22 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas } function testAddPriceSetWithMultipleTerms() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Log in using webtestLogin() method - $this->webtestLogin(); - - // add the required Drupal permission - + // add the required permission $permissions = array('edit-1-make-online-contributions'); $this->changePermissions($permissions); - $title = substr(sha1(rand()), 0, 7); - $setTitle = "Membership Fees - $title"; - $usedFor = 'Membership'; + // Log in as normal user + $this->webtestLogin(); + + $title = substr(sha1(rand()), 0, 7); + $setTitle = "Membership Fees - $title"; + $usedFor = 'Membership'; $contributionType = 'Member Dues'; - $setHelp = 'Select your membership options.'; + $setHelp = 'Select your membership options.'; $memTypeParams1 = $this->webtestAddMembershipType(); - $memTypeTitle1 = $memTypeParams1['membership_type']; - $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); - $memTypeId1 = $memTypeId1[1]; + $memTypeTitle1 = $memTypeParams1['membership_type']; + $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); + $memTypeId1 = $memTypeId1[1]; $this->_testAddSet($setTitle, $usedFor, $contributionType, $setHelp); // Get the price set id ($sid) by retrieving and parsing the URL of the New Price Field form @@ -183,8 +171,8 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $registerUrl = $this->_testVerifyRegisterPage($contributionPageTitle); $firstName = 'John_' . substr(sha1(rand()), 0, 7); - $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); - $email = "{$firstName}.{$lastName}@example.com"; + $lastName = 'Anderson_' . substr(sha1(rand()), 0, 7); + $email = "{$firstName}.{$lastName}@example.com"; $contactParams = array( 'first_name' => $firstName, @@ -227,14 +215,14 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas function _testAddPriceFields(&$fields, &$validateString, $dateSpecificFields = FALSE, $title, $sid, $contributionType) { $memTypeParams1 = $this->webtestAddMembershipType(); - $memTypeTitle1 = $memTypeParams1['membership_type']; - $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); - $memTypeId1 = $memTypeId1[1]; + $memTypeTitle1 = $memTypeParams1['membership_type']; + $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); + $memTypeId1 = $memTypeId1[1]; $memTypeParams2 = $this->webtestAddMembershipType(); - $memTypeTitle2 = $memTypeParams2['membership_type']; - $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href")); - $memTypeId2 = $memTypeId2[1]; + $memTypeTitle2 = $memTypeParams2['membership_type']; + $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href")); + $memTypeId2 = $memTypeId2[1]; $this->openCiviPage('admin/price/field', "reset=1&action=add&sid={$sid}"); @@ -308,14 +296,14 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->type('title', $contributionPageTitle); $this->click('_qf_SearchContribution_refresh'); $this->waitForPageToLoad('50000'); - $id = $this->getAttribute("//div[@id='configure_contribution_page']//div[@class='dataTables_wrapper']/table/tbody/tr@id"); - $id = explode('_', $id); + $id = $this->getAttribute("//div[@id='configure_contribution_page']//div[@class='dataTables_wrapper']/table/tbody/tr@id"); + $id = explode('_', $id); $registerUrl = array('url' => 'contribute/transact', 'args' => "reset=1&id=$id[1]"); return $registerUrl; } function _testSignUpOrRenewMembership($registerUrl, $contactParams, $memTypeTitle1, $memTypeTitle2, $renew = FALSE) { - $this->openCiviPage('logout', 'reset=1', NULL); + $this->webtestLogout(); $this->openCiviPage($registerUrl['url'], $registerUrl['args'], '_qf_Main_upload-bottom'); @@ -323,14 +311,14 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas require_once 'CRM/Core/Config.php'; require_once 'CRM/Utils/Array.php'; require_once 'CRM/Utils/Date.php'; - $currentYear = date('Y'); + $currentYear = date('Y'); $currentMonth = date('m'); - $previousDay = date('d') - 1; - $endYear = ($renew) ? $currentYear + 2 : $currentYear + 1; - $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); - $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); - $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); - $configVars = new CRM_Core_Config_Variables(); + $previousDay = date('d') - 1; + $endYear = ($renew) ? $currentYear + 2 : $currentYear + 1; + $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); + $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); + $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); + $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate') as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); @@ -374,7 +362,6 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check membership - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); @@ -438,7 +425,7 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $prevYear = substr($year, 0, 4); } - $this->openCiviPage('logout', 'reset=1', NULL); + $this->webtestLogout(); $this->openCiviPage($registerUrl['url'], $registerUrl['args'], '_qf_Main_upload-bottom'); @@ -446,20 +433,20 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas require_once 'CRM/Core/Config.php'; require_once 'CRM/Utils/Array.php'; require_once 'CRM/Utils/Date.php'; - $currentYear = date('Y'); + $currentYear = date('Y'); $currentMonth = date('m'); - $previousDay = date('d') - 1; - $endYear = ($term == 3) ? $currentYear + 3 : (($term == 2) ? $currentYear + 2 : $currentYear + 1); - $endYear = ($renew) ? $endYear + ($prevYear - $currentYear) : $endYear; - $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); - $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); - $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); - $configVars = new CRM_Core_Config_Variables(); + $previousDay = date('d') - 1; + $endYear = ($term == 3) ? $currentYear + 3 : (($term == 2) ? $currentYear + 2 : $currentYear + 1); + $endYear = ($renew) ? $endYear + ($prevYear - $currentYear) : $endYear; + $joinDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); + $startDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, date('d'), $currentYear)); + $endDate = date('Y-m-d', mktime(0, 0, 0, $currentMonth, $previousDay, $endYear)); + $configVars = new CRM_Core_Config_Variables(); foreach (array( 'joinDate', 'startDate', 'endDate') as $date) { $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); } - $i = ($term == 3) ? 3 : (($term == 2) ? 2 : 1 ); + $i = ($term == 3) ? 3 : (($term == 2) ? 2 : 1 ); $this->waitForElementPresent("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input"); $this->click("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/input"); $amount = $this->getText("xpath=//div[@id='priceset']/div[2]/div[2]/div[$i]/span/label/span[@class='crm-price-amount-amount']"); @@ -499,7 +486,6 @@ class WebTest_Member_OnlineMembershipAddPricesetTest extends CiviSeleniumTestCas $this->waitForPageToLoad($this->getTimeoutMsec()); //login to check membership - $this->open($this->sboxPath); // Log in using webtestLogin() method $this->webtestLogin(); diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipCreateTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipCreateTest.php index 05da0cb2ce..2abf1e9ada 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipCreateTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipCreateTest.php @@ -33,45 +33,38 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase { } function testOnlineMembershipCreate() { - //login with admin credentials & make sure we do have required permissions. - $this->webtestLogin(TRUE); - //check for online contribution and profile listings permissions $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); $this->changePermissions($permissions); - // now logout and login with admin credentials - $this->openCiviPage("logout", "reset=1", NULL); + // Log in as normal user + $this->webtestLogin(); // a random 7-char string and an even number to make this pass unique $hash = substr(sha1(rand()), 0, 7); $rand = 2 * rand(2, 50); - // Log in using webtestLogin() method - $this->webtestLogin(); - // We need a payment processor $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); // create contribution page with randomized title and default params - - $amountSection = TRUE; - $payLater = TRUE; + $amountSection = TRUE; + $payLater = TRUE; $allowOtherAmmount = FALSE; - $onBehalf = FALSE; - $pledges = FALSE; - $recurring = FALSE; - $memberships = TRUE; - $memPriceSetId = NULL; - $friend = TRUE; - $profilePreId = 1; - $profilePostId = NULL; - $premiums = TRUE; - $widget = FALSE; - $pcp = TRUE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = FALSE; + $memberships = TRUE; + $memPriceSetId = NULL; + $friend = TRUE; + $profilePreId = 1; + $profilePostId = NULL; + $premiums = TRUE; + $widget = FALSE; + $pcp = TRUE; $isSeparatePayment = TRUE; $contributionTitle = "Title $hash"; - $pageId = $this->webtestAddContributionPage($hash, + $pageId = $this->webtestAddContributionPage($hash, $rand, $contributionTitle, array($processorName => 'Dummy'), @@ -98,14 +91,14 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase { // create two new membership types $memTypeParams1 = $this->webtestAddMembershipType(); - $memTypeTitle1 = $memTypeParams1['membership_type']; - $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); - $memTypeId1 = $memTypeId1[1]; + $memTypeTitle1 = $memTypeParams1['membership_type']; + $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle1}']/../td[12]/span/a[3]@href")); + $memTypeId1 = $memTypeId1[1]; $memTypeParams2 = $this->webtestAddMembershipType(); - $memTypeTitle2 = $memTypeParams2['membership_type']; - $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href")); - $memTypeId2 = $memTypeId2[1]; + $memTypeTitle2 = $memTypeParams2['membership_type']; + $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/div[2]/table/tbody//tr/td[text()='{$memTypeTitle2}']/../td[12]/span/a[3]@href")); + $memTypeId2 = $memTypeId2[1]; // edit contribution page memberships tab to add two new membership types $this->openCiviPage("admin/contribute/membership", "reset=1&action=update&id={$pageId}", '_qf_MembershipBlock_next-bottom'); @@ -118,7 +111,7 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase { $this->assertElementContainsText('crm-notification-container', $text, 'Missing text: ' . $text); //logout - $this->openCiviPage("logout", "reset=1", NULL); + $this->webtestLogout(); // signup for membership 1 $firstName = 'Ma' . substr(sha1(rand()), 0, 4); @@ -174,7 +167,7 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase { // CRM-8141 signup for membership 2 with same anonymous user info (should create 2 separate membership records because membership orgs are different) //logout - $this->openCiviPage("logout", "reset=1", NULL); + $this->webtestLogout(); $this->_testOnlineMembershipSignup($pageId, $memTypeTitle2, $firstName, $lastName, $payLater, $hash); @@ -248,31 +241,32 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase { function testOnlineMembershipCreateWithContribution() { //login with admin credentials & make sure we do have required permissions. - $this->webtestLogin(TRUE); - + $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); + $this->changePermissions($permissions); + $hash = substr(sha1(rand()), 0, 7); $rand = 2 * rand(2, 50); // We need a payment processor $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); - $amountSection = TRUE; - $payLater = TRUE; + $amountSection = TRUE; + $payLater = TRUE; $allowOtherAmmount = TRUE; - $onBehalf = FALSE; - $pledges = FALSE; - $recurring = FALSE; - $memberships = TRUE; - $memPriceSetId = NULL; - $friend = FALSE; - $profilePreId = 1; - $profilePostId = NULL; - $premiums = FALSE; - $widget = FALSE; - $pcp = FALSE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = FALSE; + $memberships = TRUE; + $memPriceSetId = NULL; + $friend = FALSE; + $profilePreId = 1; + $profilePostId = NULL; + $premiums = FALSE; + $widget = FALSE; + $pcp = FALSE; $isSeparatePayment = FALSE; $membershipsRequired = FALSE; - $fixedAmount = FALSE; + $fixedAmount = FALSE; $contributionTitle = "Title $hash"; - $pageId = $this->webtestAddContributionPage($hash, + $pageId = $this->webtestAddContributionPage($hash, $rand, $contributionTitle, array($processorName => 'Dummy'), @@ -303,7 +297,7 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase { $lastName = 'An' . substr(sha1(rand()), 0, 7); //logout - $this->openCiviPage("logout", "reset=1", NULL); + $this->webtestLogout(); $this->_testOnlineMembershipSignup($pageId, 'No thank you', $firstName, $lastName, FALSE, $hash, 50); @@ -334,4 +328,4 @@ class WebTest_Member_OnlineMembershipCreateTest extends CiviSeleniumTestCase { ); $this->webtestVerifyTabularData($expected); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php b/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php index 0e6a3599f1..55fcd24784 100644 --- a/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php +++ b/tests/phpunit/WebTest/Member/OnlineMembershipRenewTest.php @@ -37,11 +37,6 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $hash = substr(sha1(rand()), 0, 7); $rand = 2 * rand(2, 50); - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -49,8 +44,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - $this->open($this->sboxPath . "civicrm/admin/contribute/amount?reset=1&action=update&id=2"); - $this->waitForElementPresent("_qf_Amount_next"); + $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", "_qf_Amount_next"); // this contribution page for membership signup // select newly created processor $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; @@ -91,16 +85,14 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForPageToLoad(); $firstName = 'Ma' . substr(sha1(rand()), 0, 4); - $lastName = 'An' . substr(sha1(rand()), 0, 7); - $email = $firstName . "@example.com"; + $lastName = 'An' . substr(sha1(rand()), 0, 7); + $email = $firstName . "@example.com"; //logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); //Go to online membership signup page - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=2"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); @@ -135,11 +127,9 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // Log in using webtestLogin() method - $this->open($this->sboxPath); $this->webtestLogin(); //Find Member - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForElementPresent("member_end_date_high"); + $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); $this->type("sort_name", "$firstName $lastName"); $this->click("_qf_Search_refresh"); @@ -163,11 +153,9 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { } //logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=2"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); @@ -200,11 +188,9 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath); $this->webtestLogin(); //Find Member - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForElementPresent("member_end_date_high"); + $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); $this->type("sort_name", "$firstName $lastName"); $this->click("_qf_Search_refresh"); @@ -233,11 +219,6 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $hash = substr(sha1(rand()), 0, 7); $rand = 2 * rand(2, 50); - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -245,8 +226,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); $this->webtestAddPaymentProcessor($processorName); - $this->open($this->sboxPath . "civicrm/admin/contribute/amount?reset=1&action=update&id=2"); - $this->waitForElementPresent('_qf_Amount_next'); + $this->openCiviPage("admin/contribute/amount", "reset=1&action=update&id=2", '_qf_Amount_next'); //this contribution page for membership signup $xpath = "xpath=//label[text() = '{$processorName}']/preceding-sibling::input[1]"; @@ -290,8 +270,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $lastName = 'An' . substr(sha1(rand()), 0, 7); //Go to online membership signup page - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=2"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'General')]"); //Type first name and last name $this->type("first_name", $firstName); @@ -323,8 +302,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Find Member - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForElementPresent("member_end_date_high"); + $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); $this->type("sort_name", "$firstName $lastName"); $this->click("_qf_Search_refresh"); @@ -352,8 +330,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { preg_quote($value) ); } - $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=2"); - $this->waitForElementPresent("_qf_Main_upload-bottom"); + $this->openCiviPage("contribute/transact", "reset=1&id=2", "_qf_Main_upload-bottom"); $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'Student')]"); //Credit Card Info @@ -371,8 +348,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //Find Member - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForElementPresent("member_end_date_high"); + $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); $this->type("sort_name", "$firstName $lastName"); $this->click("_qf_Search_refresh"); @@ -403,16 +379,19 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { } function testUpdateInheritedMembershipOnBehalfOfRenewal() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); + // Log in as admin + $this->webtestLogin('admin'); + + $this->enableComponents('CiviMember'); - // Log in using webtestLogin() method + //check for online contribution and profile listings permissions + $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); + $this->changePermissions($permissions); + + // Log in as normal user $this->webtestLogin(); - $this->open($this->sboxPath . 'civicrm/contact/add?reset=1&ct=Organization'); - $this->waitForElementPresent('_qf_Contact_cancel'); + $this->openCiviPage("contact/add", "reset=1&ct=Organization", '_qf_Contact_cancel'); $title = substr(sha1(rand()), 0, 7); $this->type('organization_name', "Organization $title"); @@ -422,7 +401,6 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->assertTrue($this->isTextPresent("Organization $title has been created.")); - // Go directly to the URL $this->open($this->sboxPath . 'civicrm/admin/member/membershipType?reset=1&action=browse'); $this->waitForPageToLoad($this->getTimeoutMsec()); @@ -459,26 +437,22 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { // We need a payment processor $processorName = "Webtest Dummy" . substr(sha1(rand()), 0, 7); - //check for online contribution and profile listings permissions - $permissions = array("edit-1-make-online-contributions", "edit-1-profile-listings-and-forms"); - $this->changePermissions($permissions); - // create contribution page with randomized title and default params - $hash = substr(sha1(rand()), 0, 7); - $rand = 2 * rand(2, 50); + $hash = substr(sha1(rand()), 0, 7); + $rand = 2 * rand(2, 50); $amountSection = FALSE; - $payLater = FALSE; - $onBehalf = FALSE; - $pledges = FALSE; - $recurring = FALSE; - $memberships = FALSE; + $payLater = FALSE; + $onBehalf = FALSE; + $pledges = FALSE; + $recurring = FALSE; + $memberships = FALSE; $memPriceSetId = NULL; - $friend = FALSE; - $profilePreId = 1; + $friend = FALSE; + $profilePreId = 1; $profilePostId = NULL; - $premiums = FALSE; - $widget = FALSE; - $pcp = FALSE; + $premiums = FALSE; + $widget = FALSE; + $pcp = FALSE; $contributionTitle = "Title $hash"; $pageId = $this->webtestAddContributionPage($hash, @@ -523,16 +497,15 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); //get Url for Live Contribution Page $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=" . $pageId); $this->waitForElementPresent('_qf_Main_upload-bottom'); $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//span/label/span[2][contains(text(),'$membershipTypeTitle')]"); - $firstName = 'Eia' . substr(sha1(rand()), 0, 4); - $lastName = 'Ande' . substr(sha1(rand()), 0, 4); - $name = $firstName . ' ' . $lastName; + $firstName = 'Eia' . substr(sha1(rand()), 0, 4); + $lastName = 'Ande' . substr(sha1(rand()), 0, 4); + $name = $firstName . ' ' . $lastName; $organisationName = 'TestOrg' . substr(sha1(rand()), 0, 7); $email = $firstName . '@example.com'; @@ -575,14 +548,11 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { // Log in using webtestLogin() method - $this->open($this->sboxPath); $this->webtestLogin(); //Find member $endDate = date('F jS, Y', strtotime(" +1 year -1 day")); - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("member_end_date_high"); + $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); $this->type("sort_name", "$organisationName"); $this->click("_qf_Search_refresh"); @@ -606,9 +576,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { ); } - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("member_end_date_high"); + $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); $this->type("sort_name", "$lastName, $firstName"); $this->click("_qf_Search_refresh"); @@ -633,8 +601,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { } //logout - $this->open($this->sboxPath . "civicrm/logout?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); $this->open($this->sboxPath . "civicrm/contribute/transact?reset=1&id=" . $pageId); @@ -679,14 +646,11 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); // Log in using webtestLogin() method - $this->open($this->sboxPath); $this->webtestLogin(); //Find member $endDate = date('F jS, Y', strtotime(" +2 year -1 day")); - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("member_end_date_high"); + $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); $this->type("sort_name", "$organisationName"); $this->click("_qf_Search_refresh"); @@ -709,9 +673,7 @@ class WebTest_Member_OnlineMembershipRenewTest extends CiviSeleniumTestCase { ); } - $this->open($this->sboxPath . "civicrm/member/search?reset=1"); - $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->waitForElementPresent("member_end_date_high"); + $this->openCiviPage("member/search", "reset=1", "member_end_date_high"); $this->type("sort_name", "$lastName, $firstName"); $this->click("_qf_Search_refresh"); diff --git a/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php b/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php index 70724c0201..41797c1e97 100644 --- a/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php +++ b/tests/phpunit/WebTest/Member/SeperateMembershipPaymentTest.php @@ -36,11 +36,6 @@ class WebTest_Member_SeperateMembershipPaymentTest extends CiviSeleniumTestCase // a random 7-char string and an even number to make this pass unique $hash = substr(sha1(rand()), 0, 7); $rand = 2 * rand(2, 50); - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -168,4 +163,4 @@ class WebTest_Member_SeperateMembershipPaymentTest extends CiviSeleniumTestCase $this->click("_qf_Confirm_next-bottom"); $this->waitForPageToLoad($this->getTimeoutMsec()); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Member/UpdateMembershipScriptTest.php b/tests/phpunit/WebTest/Member/UpdateMembershipScriptTest.php index 8575ca6165..0c9b03d197 100644 --- a/tests/phpunit/WebTest/Member/UpdateMembershipScriptTest.php +++ b/tests/phpunit/WebTest/Member/UpdateMembershipScriptTest.php @@ -33,11 +33,6 @@ class WebTest_Member_UpdateMembershipScriptTest extends CiviSeleniumTestCase { } function testAddMembership() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -133,4 +128,4 @@ class WebTest_Member_UpdateMembershipScriptTest extends CiviSeleniumTestCase { return $memTypeParams; } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php b/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php index 7d6bdbf646..450790224a 100644 --- a/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php +++ b/tests/phpunit/WebTest/Pledge/ContactContextAddTest.php @@ -33,16 +33,6 @@ class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase { } function testContactContextAddTest() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // create unique name @@ -70,7 +60,6 @@ class WebTest_Pledge_ContactContextAddTest extends CiviSeleniumTestCase { // check contact name on pledge form $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); - // Let's start filling the form with values. $this->type("amount", "100"); $this->type("installments", "10"); $this->select("frequency_unit", "value=week"); diff --git a/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php b/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php index 61be1bf37b..58ffef1427 100644 --- a/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php +++ b/tests/phpunit/WebTest/Pledge/ContactContextPledgePaymentAddTest.php @@ -33,16 +33,6 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest } function testAddPledgePaymentWithAdjustPledgePaymentSchedule() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); $this->openCiviPage('admin/setting/localization', 'reset=1'); $this->select("currencyLimit-f","value=FJD"); @@ -75,7 +65,6 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest // check contact name on pledge form $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); - // Let's start filling the form with values. $this->select("currency","value=FJD"); $this->type("amount", "30"); $this->type("installments", "3"); @@ -231,16 +220,6 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest } function testAddPledgePaymentWithAdjustTotalPledgeAmount() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // create unique name @@ -268,7 +247,6 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest // check contact name on pledge form $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); - // Let's start filling the form with values. $this->type("amount", "30"); $this->type("installments", "3"); $this->select("frequency_unit", "value=week"); @@ -406,16 +384,6 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest } function testAddPledgePayment() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // create unique name @@ -443,7 +411,6 @@ class WebTest_Pledge_ContactContextPledgePaymentAddTest extends CiviSeleniumTest // check contact name on pledge form $this->assertElementContainsText('css=tr.crm-pledge-form-block-displayName', "$firstName $lastName"); - // Let's start filling the form with values. $this->type("amount", "30"); $this->type("installments", "3"); $this->select("frequency_unit", "value=week"); diff --git a/tests/phpunit/WebTest/Pledge/StandaloneAddDeleteTest.php b/tests/phpunit/WebTest/Pledge/StandaloneAddDeleteTest.php index 23d734d205..351a7bc7b0 100644 --- a/tests/phpunit/WebTest/Pledge/StandaloneAddDeleteTest.php +++ b/tests/phpunit/WebTest/Pledge/StandaloneAddDeleteTest.php @@ -33,14 +33,8 @@ class WebTest_Pledge_StandaloneAddDeleteTest extends CiviSeleniumTestCase { } function testStandalonePledgeAddDelete() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Pledge-standalone). $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload'); // create new contact using dialog diff --git a/tests/phpunit/WebTest/Pledge/StandaloneAddTest.php b/tests/phpunit/WebTest/Pledge/StandaloneAddTest.php index 6cdc0c146c..f41579896d 100644 --- a/tests/phpunit/WebTest/Pledge/StandaloneAddTest.php +++ b/tests/phpunit/WebTest/Pledge/StandaloneAddTest.php @@ -33,14 +33,8 @@ class WebTest_Pledge_StandaloneAddTest extends CiviSeleniumTestCase { } function testStandalonePledgeAdd() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - $this->webtestLogin(); - // Go directly to the URL of the screen that you will be testing (New Pledge-standalone). $this->openCiviPage('pledge/add', 'reset=1&context=standalone', '_qf_Pledge_upload'); // create new contact using dialog diff --git a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php index 6cb490d9d8..967927d5b6 100644 --- a/tests/phpunit/WebTest/Profile/BatchUpdateTest.php +++ b/tests/phpunit/WebTest/Profile/BatchUpdateTest.php @@ -37,11 +37,6 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { } function testBatchUpdateWithContactSubtypes() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -131,11 +126,6 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { } function testBatchUpdate() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // Log in using webtestLogin() method $this->webtestLogin(); @@ -522,7 +512,7 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { } function _addProfile($profileTitle, $customDataArr, $profileFor) { - // Go directly to the URL of the screen that you will be testing (New Profile). + $this->openCiviPage('admin/uf/group', 'reset=1'); $this->click('link=Add Profile'); @@ -551,7 +541,7 @@ class WebTest_Profile_BatchUpdateTest extends CiviSeleniumTestCase { function _addCustomData($profileFor) { $returnArray = array(); $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4); - // Go directly to the URL of the screen that you will be testing (New Custom Group). + $this->openCiviPage('admin/custom/group', 'reset=1'); //add new custom data diff --git a/tests/phpunit/WebTest/Profile/DedupeTest.php b/tests/phpunit/WebTest/Profile/DedupeTest.php index f7356a16d2..e446906cf7 100644 --- a/tests/phpunit/WebTest/Profile/DedupeTest.php +++ b/tests/phpunit/WebTest/Profile/DedupeTest.php @@ -33,21 +33,18 @@ class WebTest_Profile_DedupeTest extends CiviSeleniumTestCase { } function testProfileCreateDupeStrictDefault() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - // lets give profile related permision to anonymous user. $permission = array('edit-1-profile-create', 'edit-1-profile-edit', 'edit-1-profile-listings', 'edit-1-profile-view'); $this->changePermissions($permission); - // Go directly to the URL of the screen that you will beadding New Individual. + // Log in as normal user + $this->webtestLogin(); + $this->openCiviPage('contact/add', 'reset=1&ct=Individual'); $firstName = "John" . substr(sha1(rand()), 0, 7); - $lastName = "Smith" . substr(sha1(rand()), 0, 7); - $email = $firstName . "@" . $lastName . ".com"; + $lastName = "Smith" . substr(sha1(rand()), 0, 7); + $email = $firstName . "@" . $lastName . ".com"; // fill in first name $this->type("first_name", $firstName); @@ -82,4 +79,4 @@ class WebTest_Profile_DedupeTest extends CiviSeleniumTestCase { $this->click("_qf_Edit_next"); $this->waitForTextPresent("A record already exists with the same information."); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php index 41926ad580..0019439cd5 100644 --- a/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/MultiRecordProfileAddTest.php @@ -32,55 +32,24 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { parent::setUp(); } function testAdminAddNewProfile() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); list($id, $profileTitle) = $this->_addNewProfile(); $this->_deleteProfile($id, $profileTitle); } function testUserAddNewProfile() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); list($id, $profileTitle) = $this->_addNewProfile(TRUE, FALSE, TRUE); $this->_deleteProfile($id, $profileTitle); } function testAddNewNonMultiProfile() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); list($id, $profileTitle) = $this->_addNewProfile(FALSE); $this->_deleteProfile($id, $profileTitle); } function testNonSearchableMultiProfile() { - $this->open($this->sboxPath); $this->webtestLogin(); list($id, $profileTitle) = $this->_addNewProfile(TRUE, TRUE); @@ -89,8 +58,7 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { function _addNewProfile($checkMultiRecord = TRUE, $checkSearchable = FALSE, $userCheck = FALSE) { $params = $this->_testCustomAdd($checkSearchable); - // Go directly to the URL of the screen that you will be - // testing (Add new profile ). + $this->openCiviPage('admin/uf/group', 'reset=1'); $this->click('newCiviCRMProfile-top'); @@ -227,8 +195,8 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->type('cms_confirm_pass', $recordNew['firstname']); $this->click('_qf_Useradd_next-bottom'); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->open($this->sboxPath . "user/logout"); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogout(); + $this->open("{$this->sboxPath}user"); // Make sure login form is available $this->waitForElementPresent('edit-submit'); @@ -310,10 +278,8 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { } function _testCustomAdd($checkSearchable) { - // Go directly to the URL of the screen that you will be testing (Custom data for contacts). + $this->openCiviPage('admin/custom/group', 'action=add&reset=1'); - // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit - // button at the end of this page to show up, to make sure it's fully loaded. //fill custom group title $params['customGroupTitle'] = 'custom_group' . substr(sha1(rand()), 0, 3); @@ -394,4 +360,4 @@ class WebTest_Profile_MultiRecordProfileAddTest extends CiviSeleniumTestCase { $this->click('_qf_Edit_next'); return $params; } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Profile/ProfileAddTest.php b/tests/phpunit/WebTest/Profile/ProfileAddTest.php index fb770bfd10..04f34a00ba 100644 --- a/tests/phpunit/WebTest/Profile/ProfileAddTest.php +++ b/tests/phpunit/WebTest/Profile/ProfileAddTest.php @@ -33,20 +33,9 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { } function testAddNewProfile() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen that you will be - // testing (Add new profile ). + // Add new profile. $this->openCiviPage('admin/uf/group', 'reset=1'); $this->click('newCiviCRMProfile-top'); @@ -139,4 +128,4 @@ class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase { $this->waitForElementPresent('newCiviCRMProfile-bottom'); $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted."); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php b/tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php index 6b2a08df6a..6f22496e88 100644 --- a/tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php +++ b/tests/phpunit/WebTest/Profile/ProfileGroupSubscriptionTest.php @@ -33,20 +33,9 @@ class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase } function testProfileGroupSubscription() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen that you will be - // testing (Add new profile ). + // Add new profile. $this->openCiviPage('admin/uf/group', 'reset=1'); $this->click('newCiviCRMProfile-top'); diff --git a/tests/phpunit/WebTest/Profile/SearchTest.php b/tests/phpunit/WebTest/Profile/SearchTest.php index c48eb26164..80025faa69 100644 --- a/tests/phpunit/WebTest/Profile/SearchTest.php +++ b/tests/phpunit/WebTest/Profile/SearchTest.php @@ -33,19 +33,8 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { } function testSearchProfile() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); - // Go directly to the URL of the screen where you will be // Add new profile. $this->openCiviPage('admin/uf/group', 'reset=1'); @@ -173,4 +162,4 @@ class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { $this->assertElementContainsText('crm-notification-container', 'Is this field hidden from other users'); $this->select('visibility', 'value=Public Pages and Listings'); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Release/InstallScript.php b/tests/phpunit/WebTest/Release/InstallScript.php index 797a89bc9f..0ec08c2fe7 100644 --- a/tests/phpunit/WebTest/Release/InstallScript.php +++ b/tests/phpunit/WebTest/Release/InstallScript.php @@ -38,7 +38,6 @@ class WebTest_Release_InstallScript extends WebTest_Release_ReleaseTestCase { } function testInstall() { - $this->open($this->sboxPath); $this->webtestLogin(); $this->open($this->settings->installURL); diff --git a/tests/phpunit/WebTest/Release/UpgradeScript.php b/tests/phpunit/WebTest/Release/UpgradeScript.php index c44fdac315..eb3eda3e55 100644 --- a/tests/phpunit/WebTest/Release/UpgradeScript.php +++ b/tests/phpunit/WebTest/Release/UpgradeScript.php @@ -38,7 +38,6 @@ class WebTest_Release_UpgradeScript extends WebTest_Release_ReleaseTestCase { } function testUpgrade() { - $this->open($this->sboxPath); $this->webtestLogin(); $this->open($this->settings->upgradeURL); $this->waitForTextPresent("Upgrade CiviCRM to Version"); diff --git a/tests/phpunit/WebTest/Report/AddTest.php b/tests/phpunit/WebTest/Report/AddTest.php index 792738276f..b811b6ce56 100644 --- a/tests/phpunit/WebTest/Report/AddTest.php +++ b/tests/phpunit/WebTest/Report/AddTest.php @@ -33,25 +33,14 @@ class WebTest_Report_AddTest extends CiviSeleniumTestCase { } function testAddReport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // create contact - $firstName = 'reportuser_' . substr(sha1(rand()), 0, 7); + $firstName = 'reportuser_' . substr(sha1(rand()), 0, 7); $displayName = "Anderson, $firstName"; - $emailId = "$firstName.anderson@example.org"; + $emailId = "$firstName.anderson@example.org"; $this->webtestAddContact($firstName, "Anderson", $emailId); - // Go directly to the URL of the screen that you will be testing (New Tag). $this->openCiviPage('report/contact/summary', 'reset=1', '_qf_Summary_submit' ); // enable email field @@ -94,10 +83,10 @@ class WebTest_Report_AddTest extends CiviSeleniumTestCase { $this->click("css=div.crm-report_setting-accordion div.crm-accordion-header"); $this->waitForElementPresent("title"); - $reportName = 'ContactSummary_' . substr(sha1(rand()), 0, 7); + $reportName = 'ContactSummary_' . substr(sha1(rand()), 0, 7); $reportDescription = "New Contact Summary Report"; - $emaiSubject = "Contact Summary Report"; - $emailCC = "tesmail@example.org"; + $emaiSubject = "Contact Summary Report"; + $emailCC = "tesmail@example.org"; // Fill Report Title $this->type("title", $reportName); diff --git a/tests/phpunit/WebTest/Report/DonarReportTest.php b/tests/phpunit/WebTest/Report/DonarReportTest.php index 316cda0fbc..abb4a22475 100644 --- a/tests/phpunit/WebTest/Report/DonarReportTest.php +++ b/tests/phpunit/WebTest/Report/DonarReportTest.php @@ -33,16 +33,6 @@ class WebTest_Report_DonarReportTest extends CiviSeleniumTestCase { } function testDonarReportPager() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. $this->webtestLogin(); // now create new donar detail report instance @@ -112,4 +102,4 @@ class WebTest_Report_DonarReportTest extends CiviSeleniumTestCase { // check if criteria still exits $this->assertElementContainsText('css=table.statistics-table', "Is greater than or equal to 10", "Criteria is not selected"); } -} \ No newline at end of file +} diff --git a/tests/phpunit/WebTest/Report/RolePermissionReportTest.php b/tests/phpunit/WebTest/Report/RolePermissionReportTest.php index 17b36d3d71..d9243ad149 100644 --- a/tests/phpunit/WebTest/Report/RolePermissionReportTest.php +++ b/tests/phpunit/WebTest/Report/RolePermissionReportTest.php @@ -33,17 +33,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { } function testRolePermissionReport() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); //create new roles $role1 = 'role1' . substr(sha1(rand()), 0, 7); @@ -71,8 +61,6 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $user1 = $this->_testCreateUser($roleId1); $user2 = $this->_testCreateUser($roleId2); - $this->open($this->sboxPath . "user/logout"); - $this->waitForPageToLoad($this->getTimeoutMsec()); // let's give full CiviReport permissions. $permissions = array( @@ -92,20 +80,13 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->click("add"); $this->click("_qf_Summary_submit_save"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->waitForElementPresent('edit-submit'); - $this->type('edit-name', $user2); - $this->type('edit-pass', 'Test12345'); - $this->click('edit-submit'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogin($user2, 'Test12345'); $this->openCiviPage('report/instance/1', 'reset=1'); $this->assertElementContainsText('crm-container', 'You do not have permission to access this report.'); $this->openCiviPage('report/list', 'reset=1'); - $this->openCiviPage('logout', 'reset=1', NULL); //delete roles - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); $this->open($this->sboxPath . "admin/people/permissions/roles"); $this->_roleDelete($role1); $this->_roleDelete($role2); @@ -115,17 +96,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { *check for CRM-10148 */ function testReservedReportPermission() { - // This is the path where our testing install resides. - // The rest of URL is defined in CiviSeleniumTestCase base class, in - // class attributes. - $this->open($this->sboxPath); - - // Logging in. Remember to wait for page to load. In most cases, - // you can rely on 30000 as the value that allows your test to pass, however, - // sometimes your test might fail because of this. In such cases, it's better to pick one element - // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole - // page contents loaded and you can continue your test execution. - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); //create new role $role = 'role' . substr(sha1(rand()), 0, 7); @@ -155,21 +126,12 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { ); $this->changePermissions($permissions); - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->waitForElementPresent('edit-submit'); - $this->type('edit-name', $user); - $this->type('edit-pass', 'Test12345'); - $this->click('edit-submit'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogin($user, 'Test12345'); $this->openCiviPage('report/instance/1', 'reset=1'); //check if the reserved report field is frozen $this->assertTrue($this->isElementPresent("xpath=//div[@id='instanceForm']//table[3]/tbody//tr/td[2]/tt[text()='[ ]']")); - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->webtestLogin(TRUE); // let's give full CiviReport permissions. $permissions = array( "edit-{$roleId}-access-civireport", @@ -187,13 +149,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->click("_qf_Summary_submit_save"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->waitForElementPresent('edit-submit'); - $this->type('edit-name', $user); - $this->type('edit-pass', 'Test12345'); - $this->click('edit-submit'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogin($user, 'Test12345'); $this->openCiviPage('report/instance/1', 'reset=1'); //check if the report criteria and settings is accessible @@ -201,9 +157,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->assertTrue($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='instanceForm']/table//input[@id='title']")); //login as admin and remove reserved permission - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); $this->open($this->sboxPath . "admin/people/permissions"); $this->waitForElementPresent("edit-submit"); @@ -216,13 +170,7 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); //login as user and check for absence of report criteria and settings - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->waitForElementPresent('edit-submit'); - $this->type('edit-name', $user); - $this->type('edit-pass', 'Test12345'); - $this->click('edit-submit'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogin($user, 'Test12345'); $this->openCiviPage('report/instance/1', 'reset=1'); if ($this->isElementPresent("xpath=//form[@id='Summary']/div[2]/div/div/div")) { @@ -235,30 +183,20 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->assertFalse($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='instanceForm']//input[@id='title']")); //login as admin and turn the is_reserved flag off for the instance - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); $this->openCiviPage('report/instance/1', 'reset=1'); $this->click("is_reserved"); $this->click("_qf_Summary_submit_save"); $this->waitForPageToLoad($this->getTimeoutMsec()); - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->waitForElementPresent('edit-submit'); - $this->type('edit-name', $user); - $this->type('edit-pass', 'Test12345'); - $this->click('edit-submit'); - $this->waitForPageToLoad($this->getTimeoutMsec()); + $this->webtestLogin($user, 'Test12345'); $this->openCiviPage('report/instance/1', 'reset=1'); $this->assertTrue($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='id_default']//input[@id='fields_email']")); $this->assertTrue($this->isElementPresent("xpath=//form[@id='Summary']//div[@id='instanceForm']//input[@id='title']")); //login as admin and delete the role - $this->openCiviPage('logout', 'reset=1', NULL); - $this->open($this->sboxPath); - $this->webtestLogin(TRUE); + $this->webtestLogin('admin'); $this->open($this->sboxPath . "admin/people/permissions/roles"); $this->_roleDelete($role); } @@ -275,7 +213,6 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { function _testCreateUser($roleid) { - // Go directly to the URL of the screen that will Create User Authentically. $this->open($this->sboxPath . "admin/people/create"); $this->waitForElementPresent("edit-submit"); @@ -307,4 +244,4 @@ class WebTest_Report_RolePermissionReportTest extends CiviSeleniumTestCase { $this->waitForPageToLoad($this->getTimeoutMsec()); return $name; } -} \ No newline at end of file +} -- 2.25.1