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");
92 $this->waitForTextPresent($sourceText);
94 // Is status message correct?
95 $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added.");
97 // click through to the membership view screen
98 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
99 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
102 'Membership Type' => $memTypeParams['membership_type'],
104 'Source' => $sourceText,
106 $this->webtestVerifyTabularData($verifyData);
108 $this->click("_qf_MembershipView_cancel-bottom");
110 $this->waitForTextPresent($sourceText);
112 $this->waitForElementPresent("css=li#tab_activity a");
113 // click through to the activities screen
114 $this->click("css=li#tab_activity a");
116 $this->waitForTextPresent('Membership Signup');
118 // click through to the activiy view screen (which is the membership view
119 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
120 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
123 'Membership Type' => $memTypeParams['membership_type'],
125 'Source' => $sourceText,
127 $this->webtestVerifyTabularData($verifyData);
128 $this->clickLink("_qf_MembershipView_cancel-bottom", "xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[7]", FALSE);
129 $this->click("xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[9]/span/a[2][text()='Edit']");
130 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
132 // fill in Membership Organization and Type
133 $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
134 // Wait for membership type select to reload
135 $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
136 $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
138 $this->waitForElementPresent("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]");
139 $this->click("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]/a[@title='Clear']");
141 $this->click("_qf_Membership_upload-bottom");
143 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
145 $this->waitForTextPresent($sourceText);
146 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
147 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
151 'Source' => $sourceText,
154 $this->webtestVerifyTabularData($verifyData);
157 function testMemberAddWithLifeTimeMembershipType() {
158 $this->webtestLogin();
160 // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
161 $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime');
163 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
165 $firstName = "John_" . substr(sha1(rand()), 0, 7);
168 $this->type("first_name", $firstName);
171 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);;
172 $this->type("last_name", $lastName);
175 $email = substr(sha1(rand()), 0, 7) . "john@gmail.com";
176 $this->type("email_1_email", $email);
179 $this->click("_qf_Contact_upload_view");
180 $this->waitForPageToLoad($this->getTimeoutMsec());
181 $this->waitForText('crm-notification-container', "$firstName $lastName has been created.");
183 // click through to the membership view screen
184 $this->click("css=li#tab_member a");
186 $this->waitForElementPresent("link=Add Membership");
187 $this->click("link=Add Membership");
189 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
191 // fill in Membership Organization and Type
192 $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}");
194 // Wait for membership type select to reload
195 $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']);
196 // Because it tends to cause problems, all uses of sleep() must be justified in comments
197 // Sleep should never be used for wait for anything to load from the server
198 // Justification for this instance: FIXME
200 $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}");
202 $sourceText = "Check Lifetime membership type webtest";
204 $this->type("source", $sourceText);
206 // Let Join Date stay default
208 // fill in Start Date
209 $this->webtestFillDate('start_date');
212 $this->click("_qf_Membership_upload");
215 $this->waitForTextPresent($sourceText);
217 // Is status message correct?
218 $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added.");
220 // click through to the membership view screen
221 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
222 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
226 'Source' => $sourceText,
229 $this->webtestVerifyTabularData($verifyData);
230 $this->click("_qf_MembershipView_cancel-bottom");
231 $this->waitForElementPresent("mainTabContainer");