Skip to content

Commit 55ec2e6

Browse files
committed
Merge pull request #25 from ravishnair/webtest-fixes
-- Used openCiviPage and assertElementContainsText methods in webtests
2 parents affa65d + c038a4f commit 55ec2e6

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

tests/phpunit/WebTest/Event/AddParticipationTest.php

+9-20
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ function testEventParticipationAdd() {
4949
$displayName = "$firstName Anderson";
5050

5151
// Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone).
52-
$this->open($this->sboxPath . 'civicrm/participant/add?reset=1&action=add&context=standalone');
53-
54-
// As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit
55-
// button at the end of this page to show up, to make sure it's fully loaded.
56-
$this->waitForElementPresent('_qf_Participant_upload-bottom');
52+
$this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
5753

5854
// Let's start filling the form with values.
5955
// Type contact last name in contact auto-complete, wait for dropdown and click first result
@@ -101,7 +97,7 @@ function testEventParticipationAdd() {
10197
$this->waitForPageToLoad($this->getTimeoutMsec());
10298

10399
// Is status message correct?
104-
$this->assertTrue($this->isTextPresent("Event registration for $displayName has been added"), "Status message didn't show up after saving!");
100+
$this->assertElementContainsText("crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
105101

106102
$this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
107103
//click through to the participant view screen
@@ -153,8 +149,7 @@ function testEventParticipationAddWithMultipleRoles() {
153149
$displayName = "$firstName Anderson";
154150

155151
// add custom data for participant role
156-
$this->open($this->sboxPath . 'civicrm/admin/custom/group?reset=1 ');
157-
$this->waitForPageToLoad($this->getTimeoutMsec());
152+
$this->openCiviPage("admin/custom/group", "reset=1");
158153

159154
//add new custom data
160155
$this->click("//a[@id='newCustomDataGroup']/span");
@@ -177,7 +172,7 @@ function testEventParticipationAddWithMultipleRoles() {
177172
$this->waitForPageToLoad($this->getTimeoutMsec());
178173

179174
//Is custom group created?
180-
$this->assertTrue($this->isTextPresent("Your custom field set '$customGroupTitle' has been added. You can add custom fields now."));
175+
$this->assertElementContainsText("crm-notification-container", "Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
181176

182177
//add custom field - alphanumeric checkbox
183178
$checkboxFieldLabel = 'custom_field' . substr(sha1(rand()), 0, 4);
@@ -215,7 +210,7 @@ function testEventParticipationAddWithMultipleRoles() {
215210
$this->waitForPageToLoad($this->getTimeoutMsec());
216211

217212
//Is custom field created?
218-
$this->assertTrue($this->isTextPresent("Your custom field '$checkboxFieldLabel' has been saved."));
213+
$this->assertElementContainsText("crm-notification-container", "Your custom field '$checkboxFieldLabel' has been saved.");
219214

220215
//create another custom field - Integer Radio
221216
$this->click("//a[@id='newCustomField']/span");
@@ -257,11 +252,7 @@ function testEventParticipationAddWithMultipleRoles() {
257252
$this->waitForPageToLoad($this->getTimeoutMsec());
258253

259254
// Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone).
260-
$this->open($this->sboxPath . 'civicrm/participant/add?reset=1&action=add&context=standalone');
261-
262-
// As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit
263-
// button at the end of this page to show up, to make sure it's fully loaded.
264-
$this->waitForElementPresent('_qf_Participant_upload-bottom');
255+
$this->openCiviPage("participant/add", "reset=1&action=add&context=standalone", "_qf_Participant_upload-bottom");
265256

266257
// Let's start filling the form with values.
267258
// Type contact last name in contact auto-complete, wait for dropdown and click first result
@@ -312,9 +303,7 @@ function testEventParticipationAddWithMultipleRoles() {
312303
$this->waitForPageToLoad($this->getTimeoutMsec());
313304

314305
// Is status message correct?
315-
$this->assertTrue($this->isTextPresent("Event registration for $displayName has been added"),
316-
"Status message didn't show up after saving!"
317-
);
306+
$this->assertElementContainsText("crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
318307

319308
$this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
320309
//click through to the participant view screen
@@ -369,7 +358,7 @@ function testEventAddMultipleParticipants() {
369358
$lastName2 = 'Last' . $rand;
370359

371360
// Go directly to the URL of the screen that you will be testing (Register Participant for Event-standalone).
372-
$this->open($this->sboxPath . 'civicrm/participant/add?reset=1&action=add&context=standalone&mode=test&eid=3');
361+
$this->openCiviPage("participant/add", "reset=1&action=add&context=standalone&mode=test&eid=3");
373362

374363
$this->assertTrue($this->isTextPresent("Register New Participant"), "Page title 'Register New Participant' missing");
375364
$this->assertTrue($this->isTextPresent("A TEST transaction will be submitted"), "test mode status 'A TEST transaction will be submitted' missing");
@@ -384,7 +373,7 @@ function testEventAddMultipleParticipants() {
384373
$this->waitForPageToLoad($this->getTimeoutMsec());
385374

386375
//searching the paricipants
387-
$this->open($this->sboxPath . 'civicrm/event/search?reset=1');
376+
$this->openCiviPage("event/search", "reset=1");
388377
$this->type('sort_name', $firstName);
389378
$eventName = "Rain-forest Cup Youth Soccer Tournament";
390379
$this->type("event_name", $eventName);

tests/phpunit/WebTest/Event/AddPricesetTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ function testParticipantWithDateSpecificPriceSet() {
501501
$this->click('_qf_Participant_upload-bottom');
502502
$this->waitForPageToLoad($this->getTimeoutMsec());
503503
// Is status message correct?
504-
$this->assertTrue($this->isTextPresent("Event registration for $displayName has been added"), "Status message didn't show up after saving!");
504+
$this->assertElementContainsText("css=#crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
505505

506506
$this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
507507

@@ -638,7 +638,7 @@ function testEventWithPriceSet() {
638638
$this->waitForPageToLoad($this->getTimeoutMsec());
639639

640640
// Is status message correct?
641-
$this->assertTrue($this->isTextPresent("Event registration for $displayName has been added"), "Status message didn't show up after saving!");
641+
$this->assertElementContainsText("css=#crm-notification-container", "Event registration for $displayName has been added", "Status message didn't show up after saving!");
642642

643643
$this->waitForElementPresent("xpath=//div[@id='Events']//table//tbody/tr[1]/td[8]/span/a[text()='View']");
644644
//click through to the participant view screen

0 commit comments

Comments
 (0)