Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
15a4309a | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Member_ContactContextAddTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_ContactContextAddTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testContactMemberAdd() { |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | ||
41 | // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership) | |
42 | $memTypeParams = $this->webtestAddMembershipType(); | |
43 | $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime'); | |
44 | ||
928c2d43 | 45 | $this->openCiviPage("contact/add", "reset=1&ct=Individual"); |
6a488035 TO |
46 | |
47 | $firstName = "John_" . substr(sha1(rand()), 0, 7); | |
48 | ||
49 | //fill in first name | |
50 | $this->type("first_name", $firstName); | |
51 | ||
52 | //fill in last name | |
928c2d43 | 53 | $lastName = "Smith_" . substr(sha1(rand()), 0, 7); |
6a488035 TO |
54 | $this->type("last_name", $lastName); |
55 | ||
56 | //fill in email | |
57 | $email = substr(sha1(rand()), 0, 7) . "john@gmail.com"; | |
58 | $this->type("email_1_email", $email); | |
59 | ||
60 | // Clicking save. | |
61 | $this->click("_qf_Contact_upload_view"); | |
62 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 63 | $this->waitForText('crm-notification-container', "$firstName $lastName"); |
6a488035 TO |
64 | |
65 | // click through to the membership view screen | |
66 | $this->click("css=li#tab_member a"); | |
67 | ||
68 | $this->waitForElementPresent("link=Add Membership"); | |
69 | $this->click("link=Add Membership"); | |
70 | ||
71 | $this->waitForElementPresent("_qf_Membership_cancel-bottom"); | |
72 | ||
73 | // fill in Membership Organization and Type | |
74 | $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}"); | |
75 | // Wait for membership type select to reload | |
76 | $this->waitForTextPresent($memTypeParams['membership_type']); | |
efb29358 CW |
77 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
78 | // Sleep should never be used for wait for anything to load from the server | |
79 | // Justification for this instance: FIXME | |
6a488035 TO |
80 | sleep(3); |
81 | $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}"); | |
82 | ||
83 | $sourceText = "Membership ContactAddTest Webtest"; | |
84 | // fill in Source | |
85 | $this->type("source", $sourceText); | |
86 | ||
87 | // Let Join Date stay default | |
88 | ||
89 | // fill in Start Date | |
90 | $this->webtestFillDate('start_date'); | |
91 | ||
92 | // Clicking save. | |
93 | $this->click("_qf_Membership_upload"); | |
6a488035 TO |
94 | |
95 | // page was loaded | |
96 | $this->waitForTextPresent($sourceText); | |
97 | ||
98 | // Is status message correct? | |
6c5f7368 | 99 | $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added."); |
6a488035 TO |
100 | |
101 | // click through to the membership view screen | |
102 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
103 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
104 | ||
105 | $verifyData = array( | |
106 | 'Membership Type' => $memTypeParams['membership_type'], | |
107 | 'Status' => 'New', | |
108 | 'Source' => $sourceText, | |
109 | ); | |
928c2d43 PJ |
110 | $this->webtestVerifyTabularData($verifyData); |
111 | ||
6a488035 | 112 | $this->click("_qf_MembershipView_cancel-bottom"); |
6a488035 TO |
113 | // page was loaded |
114 | $this->waitForTextPresent($sourceText); | |
115 | ||
73072f84 | 116 | $this->waitForElementPresent("css=li#tab_activity a"); |
6a488035 TO |
117 | // click through to the activities screen |
118 | $this->click("css=li#tab_activity a"); | |
119 | // page was loaded | |
120 | $this->waitForTextPresent('Membership Signup'); | |
121 | ||
122 | // click through to the activiy view screen (which is the membership view | |
123 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
124 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
125 | ||
126 | $verifyData = array( | |
127 | 'Membership Type' => $memTypeParams['membership_type'], | |
128 | 'Status' => 'New', | |
129 | 'Source' => $sourceText, | |
130 | ); | |
928c2d43 | 131 | $this->webtestVerifyTabularData($verifyData); |
73072f84 | 132 | $this->clickLink("_qf_MembershipView_cancel-bottom", "xpath=//div[@id='memberships']/div/table/tbody//tr/td[1][text()='{$memTypeParams['membership_type']}']/../td[7]", FALSE); |
6a488035 | 133 | $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 |
134 | $this->waitForElementPresent("_qf_Membership_cancel-bottom"); |
135 | ||
136 | // fill in Membership Organization and Type | |
137 | $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}"); | |
138 | // Wait for membership type select to reload | |
139 | $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']); | |
140 | $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}"); | |
141 | ||
142 | $this->waitForElementPresent("xpath=//form[@id='Membership']/div[2]/div[2]//table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]"); | |
ca0cdd20 | 143 | $this->click("xpath=//form[@id='Membership']/div[2]/div[2]/table/tbody//tr[@class='crm-membership-form-block-end_date']/td[2]/a"); |
6a488035 TO |
144 | |
145 | $this->click("_qf_Membership_upload-bottom"); | |
6a488035 | 146 | |
73072f84 | 147 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); |
6a488035 TO |
148 | // page was loaded |
149 | $this->waitForTextPresent($sourceText); | |
150 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
151 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
152 | ||
153 | $verifyData = array( | |
154 | 'Status' => 'New', | |
155 | 'Source' => $sourceText, | |
156 | 'End date' => '', | |
157 | ); | |
928c2d43 | 158 | $this->webtestVerifyTabularData($verifyData); |
6a488035 TO |
159 | } |
160 | ||
00be9182 | 161 | public function testMemberAddWithLifeTimeMembershipType() { |
6a488035 TO |
162 | $this->webtestLogin(); |
163 | ||
164 | // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership) | |
165 | $lifeTimeMemTypeParams = $this->webtestAddMembershipType('rolling', 1, 'lifetime'); | |
166 | ||
928c2d43 | 167 | $this->openCiviPage("contact/add", "reset=1&ct=Individual"); |
6a488035 TO |
168 | |
169 | $firstName = "John_" . substr(sha1(rand()), 0, 7); | |
170 | ||
171 | //fill in first name | |
172 | $this->type("first_name", $firstName); | |
173 | ||
174 | //fill in last name | |
175 | $lastName = "Smith_" . substr(sha1(rand()), 0, 7);; | |
176 | $this->type("last_name", $lastName); | |
177 | ||
178 | //fill in email | |
179 | $email = substr(sha1(rand()), 0, 7) . "john@gmail.com"; | |
180 | $this->type("email_1_email", $email); | |
181 | ||
182 | // Clicking save. | |
183 | $this->click("_qf_Contact_upload_view"); | |
184 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 185 | $this->waitForText('crm-notification-container', "$firstName $lastName has been created."); |
6a488035 TO |
186 | |
187 | // click through to the membership view screen | |
188 | $this->click("css=li#tab_member a"); | |
189 | ||
190 | $this->waitForElementPresent("link=Add Membership"); | |
191 | $this->click("link=Add Membership"); | |
192 | ||
193 | $this->waitForElementPresent("_qf_Membership_cancel-bottom"); | |
194 | ||
195 | // fill in Membership Organization and Type | |
196 | $this->select("membership_type_id[0]", "label={$lifeTimeMemTypeParams['member_of_contact']}"); | |
197 | ||
198 | // Wait for membership type select to reload | |
199 | $this->waitForTextPresent($lifeTimeMemTypeParams['membership_type']); | |
efb29358 CW |
200 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
201 | // Sleep should never be used for wait for anything to load from the server | |
202 | // Justification for this instance: FIXME | |
6a488035 TO |
203 | sleep(3); |
204 | $this->select("membership_type_id[1]", "label={$lifeTimeMemTypeParams['membership_type']}"); | |
205 | ||
206 | $sourceText = "Check Lifetime membership type webtest"; | |
207 | // fill in Source | |
208 | $this->type("source", $sourceText); | |
209 | ||
210 | // Let Join Date stay default | |
211 | ||
212 | // fill in Start Date | |
213 | $this->webtestFillDate('start_date'); | |
214 | ||
215 | // Clicking save. | |
216 | $this->click("_qf_Membership_upload"); | |
6a488035 TO |
217 | |
218 | // page was loaded | |
219 | $this->waitForTextPresent($sourceText); | |
220 | ||
221 | // Is status message correct? | |
6c5f7368 | 222 | $this->waitForText('crm-notification-container', "membership for $firstName $lastName has been added."); |
6a488035 TO |
223 | |
224 | // click through to the membership view screen | |
225 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
226 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
227 | ||
228 | $verifyData = array( | |
229 | 'Status' => 'New', | |
230 | 'Source' => $sourceText, | |
231 | 'End date' => '', | |
232 | ); | |
928c2d43 | 233 | $this->webtestVerifyTabularData($verifyData); |
6a488035 | 234 | $this->click("_qf_MembershipView_cancel-bottom"); |
d17bd806 | 235 | $this->waitForElementPresent("mainTabContainer"); |
6a488035 | 236 | } |
96025800 | 237 | |
6a488035 | 238 | } |