<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
+--------------------------------------------------------------------+
*/
-
require_once 'CiviTest/CiviSeleniumTestCase.php';
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);
// add to group
$this->select("group_id", "label=$groupName");
$this->click("_qf_GroupContact_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->waitForElementPresent('link=Remove');
$firstName2 = substr(sha1(rand()), 0, 7);
$this->webtestAddContact($firstName2, "John", "$firstName2.john@example.org");
// add to group
$this->select("group_id", "label=$groupName");
$this->click("_qf_GroupContact_next");
- $this->waitForPageToLoad($this->getTimeoutMsec());
+ $this->waitForElementPresent('link=Remove');
// 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);
"Status message didn't show up after saving campaign!"
);
- $this->waitForElementPresent("//div[@id='campaignList']/div[@class='dataTables_wrapper']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]");
- $id = (int) $this->getText("//div[@id='campaignList']/div[@class='dataTables_wrapper']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]");
+ $this->waitForElementPresent("//div[@id='campaignList']/div[@id='campaigns_wrapper']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]");
+ $id = (int) $this->getText("//div[@id='campaignList']/div[@id='campaigns_wrapper']/table/tbody/tr/td[text()='{$campaignTitle}']/../td[1]");
$this->offlineParticipantAddTest($campaignTitle, $id);
}
function offlineParticipantAddTest($campaignTitle, $id) {
// connect campaign with event
- $this->open($this->sboxPath . "civicrm/event/manage&reset=1");
+ $this->openCiviPage("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");
+ $this->waitForElementPresent('title');
+ $eventName = $this->getAttribute("//*[@id='title']@value");
// select campaign
$this->click("campaign_id");
$this->select("campaign_id", "value=$id");
+ $this->waitForElementPresent('_qf_EventInfo_upload_done-bottom');
$this->click("_qf_EventInfo_upload_done-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
$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");
+ $this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
- // 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");
-
- // 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->webtestFillAutocomplete($firstName, 'contact_id');
// Select event. Based on label for now.
- $this->select("event_id", "value=$eventId");
+ $this->select2("event_id", $eventName);
// Select role
- $this->click("role_id[2]");
+ $this->multiselect2("role_id", array('Volunteer'));
// Choose Registration Date.
// Using helper webtestFillDate function.
// Select an event fee
$this->waitForElementPresent('priceset');
- $this->click("xpath=//div[@id='priceset']//input[1][@class='form-radio']");
-
+ $this->click("xpath=//*[@id='priceset']//input[1][@class='crm-form-radio']");
+
// Select 'Record Payment'
$this->click("record_contribution");
$this->type("check_number", "1044");
// go for the chicken combo (obviously)
- // $this->click("CIVICRM_QFID_chicken_Chicken");
+ // $this->click("CIVICRM_QFID_chicken_Chicken");
// Clicking save.
$this->click("_qf_Participant_upload-bottom");
$this->waitForPageToLoad($this->getTimeoutMsec());
// Is status message correct?
- $this->assertTrue($this->isTextPresent("Event registration for $displayName has been added"), "Status message didn't show up after saving!");
+ $this->waitForText("crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
- $this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
+ $this->waitForElementPresent("xpath=//*[@id='Search']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
//click through to the participant view screen
- $this->click("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
+ $this->click("xpath=//*[@id='Search']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
$this->waitForElementPresent("_qf_ParticipantView_cancel-bottom");
// 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");
$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");
- $this->waitForElementPresent("_qf_Search_next_print");
+ $this->waitForElementPresent("xpath=//div[@id='participantSearch']");
$this->click("xpath=//div[@id='participantSearch']/table/tbody/tr/td[11]/span/a[text()='Edit']");
$this->waitForElementPresent("_qf_Participant_cancel-bottom");
$this->assertTrue($this->isTextPresent("$campaignTitle"));
}
function registerUrl() {
- $this->open($this->sboxPath . 'civicrm/event/manage?reset=1');
- $this->waitForPageToLoad($this->getTimeoutMsec());
- $eventId = explode('_', $this->getAttribute("//div[@id='event_status_id']//table/tbody/tr@id"));
+ $this->openCiviPage("event/manage", "reset=1");
+ $eventId = explode('-', $this->getAttribute("//div[@id='event_status_id']//div[2]/table/tbody/tr@id"));
return $eventId[1];
}
+
}