Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Member_ContactContextAddTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testContactMemberAdd() { | |
6a488035 TO |
35 | $this->webtestLogin(); |
36 | ||
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'); | |
40 | ||
928c2d43 | 41 | $this->openCiviPage("contact/add", "reset=1&ct=Individual"); |
6a488035 TO |
42 | |
43 | $firstName = "John_" . substr(sha1(rand()), 0, 7); | |
44 | ||
45 | //fill in first name | |
46 | $this->type("first_name", $firstName); | |
47 | ||
48 | //fill in last name | |
928c2d43 | 49 | $lastName = "Smith_" . substr(sha1(rand()), 0, 7); |
6a488035 TO |
50 | $this->type("last_name", $lastName); |
51 | ||
52 | //fill in email | |
53 | $email = substr(sha1(rand()), 0, 7) . "john@gmail.com"; | |
54 | $this->type("email_1_email", $email); | |
55 | ||
56 | // Clicking save. | |
57 | $this->click("_qf_Contact_upload_view"); | |
58 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 59 | $this->waitForText('crm-notification-container', "$firstName $lastName"); |
6a488035 TO |
60 | |
61 | // click through to the membership view screen | |
62 | $this->click("css=li#tab_member a"); | |
63 | ||
64 | $this->waitForElementPresent("link=Add Membership"); | |
65 | $this->click("link=Add Membership"); | |
66 | ||
67 | $this->waitForElementPresent("_qf_Membership_cancel-bottom"); | |
68 | ||
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']); | |
efb29358 CW |
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 | |
6a488035 TO |
76 | sleep(3); |
77 | $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}"); | |
78 | ||
79 | $sourceText = "Membership ContactAddTest Webtest"; | |
80 | // fill in Source | |
81 | $this->type("source", $sourceText); | |
82 | ||
83 | // Let Join Date stay default | |
84 | ||
85 | // fill in Start Date | |
86 | $this->webtestFillDate('start_date'); | |
87 | ||
88 | // Clicking save. | |
89 | $this->click("_qf_Membership_upload"); | |
6a488035 TO |
90 | |
91 | // page was loaded | |
92 | $this->waitForTextPresent($sourceText); | |
93 | ||
94 | // Is status message correct? | |
6c5f7368 | 95 | $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added."); |
6a488035 TO |
96 | |
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"); | |
100 | ||
101 | $verifyData = array( | |
102 | 'Membership Type' => $memTypeParams['membership_type'], | |
103 | 'Status' => 'New', | |
104 | 'Source' => $sourceText, | |
105 | ); | |
928c2d43 PJ |
106 | $this->webtestVerifyTabularData($verifyData); |
107 | ||
6a488035 | 108 | $this->click("_qf_MembershipView_cancel-bottom"); |
6a488035 TO |
109 | // page was loaded |
110 | $this->waitForTextPresent($sourceText); | |
111 | ||
73072f84 | 112 | $this->waitForElementPresent("css=li#tab_activity a"); |
6a488035 TO |
113 | // click through to the activities screen |
114 | $this->click("css=li#tab_activity a"); | |
115 | // page was loaded | |
116 | $this->waitForTextPresent('Membership Signup'); | |
117 | ||
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"); | |
121 | ||
122 | $verifyData = array( | |
123 | 'Membership Type' => $memTypeParams['membership_type'], | |
124 | 'Status' => 'New', | |
125 | 'Source' => $sourceText, | |
126 | ); | |
928c2d43 | 127 | $this->webtestVerifyTabularData($verifyData); |
73072f84 | 128 | $this->clickLink("_qf_MembershipView_cancel-bottom", "xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[7]", FALSE); |
6a488035 | 129 | $this->click("xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[9]/span/a[2][text()='Edit']"); |
6a488035 TO |
130 | $this->waitForElementPresent("_qf_Membership_cancel-bottom"); |
131 | ||
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']}"); | |
137 | ||
138 | $this->waitForElementPresent("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]"); | |
d17bd806 | 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']"); |
6a488035 TO |
140 | |
141 | $this->click("_qf_Membership_upload-bottom"); | |
6a488035 | 142 | |
73072f84 | 143 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); |
6a488035 TO |
144 | // page was loaded |
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"); | |
148 | ||
149 | $verifyData = array( | |
150 | 'Status' => 'New', | |
151 | 'Source' => $sourceText, | |
152 | 'End date' => '', | |
153 | ); | |
928c2d43 | 154 | $this->webtestVerifyTabularData($verifyData); |
6a488035 TO |
155 | } |
156 | ||
157 | function testMemberAddWithLifeTimeMembershipType() { | |
6a488035 TO |
158 | $this->webtestLogin(); |
159 | ||
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'); | |
162 | ||
928c2d43 | 163 | $this->openCiviPage("contact/add", "reset=1&ct=Individual"); |
6a488035 TO |
164 | |
165 | $firstName = "John_" . substr(sha1(rand()), 0, 7); | |
166 | ||
167 | //fill in first name | |
168 | $this->type("first_name", $firstName); | |
169 | ||
170 | //fill in last name | |
171 | $lastName = "Smith_" . substr(sha1(rand()), 0, 7);; | |
172 | $this->type("last_name", $lastName); | |
173 | ||
174 | //fill in email | |
175 | $email = substr(sha1(rand()), 0, 7) . "john@gmail.com"; | |
176 | $this->type("email_1_email", $email); | |
177 | ||
178 | // Clicking save. | |
179 | $this->click("_qf_Contact_upload_view"); | |
180 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 181 | $this->waitForText('crm-notification-container', "$firstName $lastName has been created."); |
6a488035 TO |
182 | |
183 | // click through to the membership view screen | |
184 | $this->click("css=li#tab_member a"); | |
185 | ||
186 | $this->waitForElementPresent("link=Add Membership"); | |
187 | $this->click("link=Add Membership"); | |
188 | ||
189 | $this->waitForElementPresent("_qf_Membership_cancel-bottom"); | |
190 | ||
191 | // fill in Membership Organization and Type | |
192 | $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}"); | |
193 | ||
194 | // Wait for membership type select to reload | |
195 | $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']); | |
efb29358 CW |
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 | |
6a488035 TO |
199 | sleep(3); |
200 | $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}"); | |
201 | ||
202 | $sourceText = "Check Lifetime membership type webtest"; | |
203 | // fill in Source | |
204 | $this->type("source", $sourceText); | |
205 | ||
206 | // Let Join Date stay default | |
207 | ||
208 | // fill in Start Date | |
209 | $this->webtestFillDate('start_date'); | |
210 | ||
211 | // Clicking save. | |
212 | $this->click("_qf_Membership_upload"); | |
6a488035 TO |
213 | |
214 | // page was loaded | |
215 | $this->waitForTextPresent($sourceText); | |
216 | ||
217 | // Is status message correct? | |
6c5f7368 | 218 | $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added."); |
6a488035 TO |
219 | |
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"); | |
223 | ||
224 | $verifyData = array( | |
225 | 'Status' => 'New', | |
226 | 'Source' => $sourceText, | |
227 | 'End date' => '', | |
228 | ); | |
928c2d43 | 229 | $this->webtestVerifyTabularData($verifyData); |
6a488035 | 230 | $this->click("_qf_MembershipView_cancel-bottom"); |
d17bd806 | 231 | $this->waitForElementPresent("mainTabContainer"); |
6a488035 TO |
232 | } |
233 | } | |
234 |