3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License along with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Member_ContactContextAddTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testContactMemberAdd() {
35 $this->webtestLogin();
37 // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
38 $memTypeParams = $this->webtestAddMembershipType();
39 $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime');
41 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
43 $firstName = "John_" . substr(sha1(rand()), 0, 7);
46 $this->type("first_name", $firstName);
49 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);
50 $this->type("last_name", $lastName);
53 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
54 $this->type("email_1_email", $email);
57 $this->click("_qf_Contact_upload_view");
58 $this->waitForPageToLoad($this->getTimeoutMsec());
59 $this->waitForText('crm-notification-container', "$firstName $lastName");
61 // click through to the membership view screen
62 $this->click("css=li#tab_member a");
64 $this->waitForElementPresent("link=Add Membership");
65 $this->click("link=Add Membership");
67 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
69 // fill in Membership Organization and Type
70 $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}");
71 // Wait for membership type select to reload
72 $this->waitForTextPresent($memTypeParams['membership_type']);
73 // Because it tends to cause problems, all uses of sleep() must be justified in comments
74 // Sleep should never be used for wait for anything to load from the server
75 // Justification for this instance: FIXME
77 $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}");
79 $sourceText = "Membership ContactAddTest Webtest";
81 $this->type("source", $sourceText);
83 // Let Join Date stay default
86 $this->webtestFillDate('start_date');
89 $this->click("_qf_Membership_upload");
90 $this->waitForPageToLoad($this->getTimeoutMsec());
93 $this->waitForTextPresent($sourceText);
95 // Is status message correct?
96 $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added.");
98 // click through to the membership view screen
99 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
100 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
103 'Membership Type' => $memTypeParams['membership_type'],
105 'Source' => $sourceText,
107 $this->webtestVerifyTabularData($verifyData);
109 $this->click("_qf_MembershipView_cancel-bottom");
110 $this->waitForPageToLoad($this->getTimeoutMsec());
112 $this->waitForTextPresent($sourceText);
114 // click through to the activities screen
115 $this->click("css=li#tab_activity a");
117 $this->waitForTextPresent('Membership Signup');
119 // click through to the activiy view screen (which is the membership view
120 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
121 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
124 'Membership Type' => $memTypeParams['membership_type'],
126 'Source' => $sourceText,
128 $this->webtestVerifyTabularData($verifyData);
129 $this->clickLink("_qf_MembershipView_cancel-bottom", "xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[7]");
130 $this->click("xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[9]/span/a[2][text()='Edit']");
131 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
133 // fill in Membership Organization and Type
134 $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
135 // Wait for membership type select to reload
136 $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
137 $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
139 $this->waitForElementPresent("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]");
140 $this->click("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]/span/a[text()='clear']");
142 $this->click("_qf_Membership_upload-bottom");
143 $this->waitForPageToLoad($this->getTimeoutMsec());
146 $this->waitForTextPresent($sourceText);
147 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
148 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
152 'Source' => $sourceText,
155 $this->webtestVerifyTabularData($verifyData);
158 function testMemberAddWithLifeTimeMembershipType() {
159 $this->webtestLogin();
161 // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
162 $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime');
164 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
166 $firstName = "John_" . substr(sha1(rand()), 0, 7);
169 $this->type("first_name", $firstName);
172 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
173 $this->type("last_name", $lastName);
176 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
177 $this->type("email_1_email", $email);
180 $this->click("_qf_Contact_upload_view");
181 $this->waitForPageToLoad($this->getTimeoutMsec());
182 $this->waitForText('crm-notification-container', "$firstName $lastName has been created.");
184 // click through to the membership view screen
185 $this->click("css=li#tab_member a");
187 $this->waitForElementPresent("link=Add Membership");
188 $this->click("link=Add Membership");
190 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
192 // fill in Membership Organization and Type
193 $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
195 // Wait for membership type select to reload
196 $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
197 // Because it tends to cause problems, all uses of sleep() must be justified in comments
198 // Sleep should never be used for wait for anything to load from the server
199 // Justification for this instance: FIXME
201 $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
203 $sourceText = "Check Lifetime membership type webtest";
205 $this->type("source", $sourceText);
207 // Let Join Date stay default
209 // fill in Start Date
210 $this->webtestFillDate('start_date');
213 $this->click("_qf_Membership_upload");
214 $this->waitForPageToLoad($this->getTimeoutMsec());
217 $this->waitForTextPresent($sourceText);
219 // Is status message correct?
220 $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added.");
222 // click through to the membership view screen
223 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
224 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
228 'Source' => $sourceText,
231 $this->webtestVerifyTabularData($verifyData);
232 $this->click("_qf_MembershipView_cancel-bottom");
233 $this->waitForPageToLoad($this->getTimeoutMsec());