Skip to content

Commit

Permalink
Merge pull request #23 from pratik-joshi/webtests-cleanup
Browse files Browse the repository at this point in the history
Webtests cleanup
  • Loading branch information
kurund committed Mar 4, 2013
2 parents 7038be5 + 0ff7ff9 commit 30c0b0b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 104 deletions.
24 changes: 9 additions & 15 deletions tests/phpunit/WebTest/Member/EditMembershipTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/*
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
+--------------------------------------------------------------------+
Expand All @@ -24,7 +24,6 @@
+--------------------------------------------------------------------+
*/


require_once 'CiviTest/CiviSeleniumTestCase.php';
class WebTest_Member_EditMembershipTest extends CiviSeleniumTestCase {
protected function setUp() {
Expand All @@ -45,9 +44,7 @@ function testEditMembershipActivityTypes() {
$membershipTypes = $this->webtestAddMembershipType();

// now add membership
$this->open($this->sboxPath . "civicrm/member/add?reset=1&action=add&context=standalone");

$this->waitForElementPresent("_qf_Membership_upload");
$this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");

// select contact
$this->webtestFillAutocomplete($contactName);
Expand All @@ -69,13 +66,11 @@ function testEditMembershipActivityTypes() {
$this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
$this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
$expected = array(
2 => $membershipTypes['membership_type'],
3 => 'New',
4 => 'Membership StandaloneAddTest Webtest',
'Membership Type' => $membershipTypes['membership_type'],
'Status' => 'New',
'Source' => 'Membership StandaloneAddTest Webtest',
);
foreach ($expected as $label => $value) {
$this->verifyText("xpath=id('MembershipView')/div[2]/div/table[1]/tbody/tr[$label]/td[2]", preg_quote($value));
}
$this->webtestVerifyTabularData($expected);

// now edit and update type and status
$this->click("crm-membership-edit-button-top");
Expand All @@ -90,8 +85,8 @@ function testEditMembershipActivityTypes() {
$this->waitForElementPresent("access");

// Use activity search to find the expected activities
$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", $contactName);
$this->click('activity_type_id[35]');
$this->click('activity_type_id[36]');
Expand All @@ -105,5 +100,4 @@ function testEditMembershipActivityTypes() {
$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}']"));
}
}

}
33 changes: 13 additions & 20 deletions tests/phpunit/WebTest/Member/InheritedMembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
+--------------------------------------------------------------------+
*/


require_once 'CiviTest/CiviSeleniumTestCase.php';
class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase {
protected function setUp() {
Expand All @@ -40,19 +39,17 @@ function testInheritedMembership() {
// 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");
$this->type('email_1_email', "$title@org.com");
$this->click('_qf_Contact_upload_view');
$this->waitForPageToLoad($this->getTimeoutMsec());
$this->assertTrue($this->isTextPresent("Organization $title has been created."));
$this->assertElementContainsText('crm-notification-container', "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());
$this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse');

$this->click('link=Add Membership Type');
$this->waitForElementPresent('_qf_MembershipType_cancel-bottom');
Expand All @@ -78,10 +75,9 @@ function testInheritedMembership() {

$this->click('_qf_MembershipType_upload-bottom');
$this->waitForElementPresent('link=Add Membership Type');
$this->assertTrue($this->isTextPresent("The membership type 'Membership Type $title' has been saved."));
$this->assertElementContainsText('crm-notification-container', "The membership type 'Membership Type $title' has been saved.");

$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');

// creating another Orgnization
$title1 = substr(sha1(rand()), 0, 7);
Expand Down Expand Up @@ -114,9 +110,8 @@ function testInheritedMembership() {
$this->waitForTextPresent($sourceText);

// Is status message correct?
$this->assertTrue($this->isTextPresent("Membership Type $title membership for Organization $title1 has been added."),
"Status message didn't show up after saving!"
);
$this->assertElementContainsText('crm-notification-container', "Membership Type $title membership for Organization $title1 has been added.",
"Status message didn't show up after saving!");

// click through to the membership view screen
$this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
Expand All @@ -130,7 +125,7 @@ function testInheritedMembership() {
'joinDate', 'startDate', 'endDate') as $date) {
$$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull);
}

$this->webtestVerifyTabularData(
array(
'Membership Type' => "Membership Type $title",
Expand Down Expand Up @@ -211,21 +206,20 @@ function testInheritedMembership() {
$this->click('_qf_Relationship_upload');
$this->waitForElementPresent('inactive-relationships');
//check the status message
$this->assertTrue($this->isTextPresent('Relationship record has been updated.'));
$this->assertElementContainsText('crm-notification-container', 'Relationship record has been updated.');

// click through to the membership view screen
$this->click('css=li#tab_member a');

//verify inherited membership has been removed
$this->open($this->sboxPath . "civicrm/contact/view?reset=1&cid=$id&selectedChild=member");
$this->waitForElementPresent("xpath=//div[@class='crm-container-snippet']/div/div[3]");
$this->openCiviPage("contact/view", "reset=1&cid=$id&selectedChild=member", "xpath=//div[@class='crm-container-snippet']/div/div[3]");
$this->assertTrue($this->isTextPresent('No memberships have been recorded for this contact.'));

// visit relationship tab and re-enable the relationship
$this->click('css=li#tab_rel a');
$this->waitForElementPresent('css=div.action-link');
$this->click("//li[@id='tab_rel']/a");

$this->waitForElementPresent("xpath=//div[@id='inactive-relationships']//div//table/tbody//tr/td[7]/span/a[text()='Edit']");
$this->click("xpath=//div[@id='inactive-relationships']//div//table/tbody//tr/td[7]/span/a[text()='Edit']");
$this->waitForElementPresent('is_active');
Expand All @@ -235,7 +229,7 @@ function testInheritedMembership() {
$this->click('_qf_Relationship_upload');
$this->waitForElementPresent('current-relationships');
//check the status message
$this->assertTrue($this->isTextPresent('Relationship record has been updated.'));
$this->assertElementContainsText('crm-notification-container', 'Relationship record has been updated.');

//check for memberships
$this->click('css=li#tab_member a');
Expand All @@ -255,8 +249,7 @@ function testInheritedMembership() {
sleep(10);

//verify inherited membership has been removed
$this->open($this->sboxPath . "civicrm/contact/view?reset=1&cid=$id&selectedChild=member");
$this->waitForElementPresent("xpath=//div[@class='crm-container-snippet']/div/div[3]");
$this->openCiviPage("contact/view", "reset=1&cid={$id}&selectedChild=member", "xpath=//div[@class='crm-container-snippet']/div/div[3]");
$this->assertTrue($this->isTextPresent('No memberships have been recorded for this contact.'));

//enable relationship
Expand Down
Loading

0 comments on commit 30c0b0b

Please sign in to comment.