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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Member_InheritedMembershipTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { |
33 | protected function setUp() { | |
34 | parent::setUp(); | |
35 | } | |
36 | ||
37 | function testInheritedMembership() { | |
6a488035 TO |
38 | // Log in using webtestLogin() method |
39 | $this->webtestLogin(); | |
40 | ||
9d15e987 | 41 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
6a488035 TO |
42 | |
43 | $title = substr(sha1(rand()), 0, 7); | |
44 | $this->type('organization_name', "Organization $title"); | |
45 | $this->type('email_1_email', "$title@org.com"); | |
46 | $this->click('_qf_Contact_upload_view'); | |
47 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
6c5f7368 | 48 | $this->waitForText('crm-notification-container', "Organization {$title} has been created."); |
6a488035 | 49 | |
9d15e987 | 50 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); |
6a488035 TO |
51 | |
52 | $this->click('link=Add Membership Type'); | |
53 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
54 | ||
55 | $this->type('name', "Membership Type $title"); | |
56 | ||
fc2fa8f8 | 57 | $this->select2('member_of_contact_id', $title); |
6a488035 TO |
58 | |
59 | $this->type('minimum_fee', '100'); | |
60 | $this->select( 'financial_type_id', 'value=2' ); | |
61 | $this->type('duration_interval', 1); | |
62 | $this->select('duration_unit', 'label=year'); | |
63 | ||
fc2fa8f8 | 64 | $this->select('period_type', 'value=rolling'); |
6a488035 TO |
65 | |
66 | $this->removeSelection('relationship_type_id', 'label=- select -'); | |
67 | $this->addSelection('relationship_type_id', 'label=Employer of'); | |
68 | ||
69 | $this->type('max_related', '5'); | |
70 | ||
71 | $this->click('_qf_MembershipType_upload-bottom'); | |
72 | $this->waitForElementPresent('link=Add Membership Type'); | |
6c5f7368 | 73 | $this->waitForText('crm-notification-container', "Membership Type $title"); |
6a488035 | 74 | |
9d15e987 | 75 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
6a488035 TO |
76 | |
77 | // creating another Orgnization | |
78 | $title1 = substr(sha1(rand()), 0, 7); | |
79 | $this->type('organization_name', "Organization $title1"); | |
80 | $this->type('email_1_email', "$title1@org.com"); | |
81 | $this->click('_qf_Contact_upload_view'); | |
82 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
83 | ||
84 | // click through to the membership view screen | |
85 | $this->click('css=li#tab_member a'); | |
86 | ||
87 | $this->waitForElementPresent('link=Add Membership'); | |
88 | $this->click('link=Add Membership'); | |
89 | ||
90 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
91 | ||
92 | // fill in Membership Organization and Type | |
93 | $this->select('membership_type_id[0]', "label=Organization $title"); | |
94 | $this->select('membership_type_id[1]', "label=Membership Type $title"); | |
95 | ||
96 | $sourceText = 'Membership ContactAddTest with Fixed Membership Type'; | |
97 | // fill in Source | |
98 | $this->type('source', $sourceText); | |
99 | ||
100 | // Clicking save. | |
101 | $this->click('_qf_Membership_upload'); | |
fc2fa8f8 | 102 | $this->waitForElementPresent('link=Add Membership'); |
6a488035 TO |
103 | |
104 | // page was loaded | |
105 | $this->waitForTextPresent($sourceText); | |
106 | ||
107 | // Is status message correct? | |
6c5f7368 | 108 | $this->waitForText('crm-notification-container', "Membership Type $title"); |
6a488035 TO |
109 | |
110 | // click through to the membership view screen | |
111 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
112 | $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); | |
113 | ||
114 | $joinDate = date('Y-m-d'); | |
115 | $startDate = date('Y-m-d'); | |
116 | $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y') + 1)); | |
117 | $configVars = new CRM_Core_Config_Variables(); | |
118 | foreach (array( | |
119 | 'joinDate', 'startDate', 'endDate') as $date) { | |
120 | $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); | |
121 | } | |
9d15e987 | 122 | |
6a488035 TO |
123 | $this->webtestVerifyTabularData( |
124 | array( | |
125 | 'Membership Type' => "Membership Type $title", | |
126 | 'Status' => 'New', | |
127 | 'Source' => $sourceText, | |
128 | 'Member Since' => $joinDate, | |
129 | 'Start date' => $startDate, | |
130 | 'End date' => $endDate, | |
131 | 'Max related' => "5" | |
132 | ) | |
133 | ); | |
134 | ||
135 | // Adding contact | |
136 | // We're using Quick Add block on the main page for this. | |
137 | $firstName = substr(sha1(rand()), 0, 7); | |
138 | $this->webtestAddContact($firstName, 'Anderson', "$firstName@anderson.name"); | |
139 | ||
140 | // visit relationship tab | |
141 | $this->click('css=li#tab_rel a'); | |
142 | $this->waitForElementPresent('css=div.action-link'); | |
fc2fa8f8 | 143 | $this->click("//div[@class='action-link']/a/span"); |
144 | $this->waitForElementPresent('_qf_Relationship_cancel-bottom'); | |
6a488035 TO |
145 | $this->click('relationship_type_id'); |
146 | $this->select('relationship_type_id', 'label=Employee of'); | |
147 | ||
6a488035 | 148 | |
fc2fa8f8 | 149 | $this->select2('related_contact_id', $title1, TRUE); |
6a488035 TO |
150 | |
151 | $description = 'Well here is some description !!!!'; | |
152 | $this->type('description', $description); | |
153 | ||
154 | //save the relationship | |
fc2fa8f8 | 155 | $this->click('_qf_Relationship_upload-bottom'); |
cebea087 | 156 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); |
6a488035 | 157 | //check the status message |
fc2fa8f8 | 158 | $this->waitForText('crm-notification-container', 'Relationship created.'); |
6a488035 | 159 | |
cebea087 | 160 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='View']"); |
6a488035 TO |
161 | |
162 | // click through to the membership view screen | |
163 | $this->click('css=li#tab_member a'); | |
164 | $this->waitForElementPresent('css=div#memberships'); | |
165 | ||
166 | // click through to the membership view screen | |
167 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
168 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
169 | ||
170 | $this->webtestVerifyTabularData( | |
171 | array( | |
172 | 'Membership Type' => "Membership Type $title", | |
173 | 'Status' => 'New', | |
174 | 'Source' => $sourceText, | |
175 | 'Member Since' => $joinDate, | |
176 | 'Start date' => $startDate, | |
177 | 'End date' => $endDate, | |
178 | ) | |
179 | ); | |
180 | $this->click("_qf_MembershipView_cancel-bottom"); | |
181 | $this->waitForElementPresent('css=div#memberships'); | |
182 | ||
183 | //1. change relationship status on form | |
184 | $this->click('css=li#tab_rel a'); | |
185 | $this->waitForElementPresent('css=div.action-link'); | |
186 | ||
187 | $this->click("//li[@id='tab_rel']/a"); | |
cebea087 | 188 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); |
189 | $id = explode('&id=', $this->getAttribute("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a@href")); | |
fc2fa8f8 | 190 | $id = explode('&', $id[0]); |
191 | $id = explode('=', $id[2]); | |
192 | $id = $id[1]; | |
cebea087 | 193 | $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); |
6a488035 TO |
194 | |
195 | $this->waitForElementPresent('is_active'); | |
196 | //disable relationship | |
197 | if ($this->isChecked('is_active')) { | |
198 | $this->click('is_active'); | |
199 | } | |
200 | $this->click('_qf_Relationship_upload'); | |
cebea087 | 201 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); |
6a488035 | 202 | //check the status message |
6c5f7368 | 203 | $this->waitForText('crm-notification-container', 'Relationship record has been updated'); |
6a488035 TO |
204 | |
205 | // click through to the membership view screen | |
206 | $this->click('css=li#tab_member a'); | |
207 | ||
208 | //verify inherited membership has been removed | |
fc2fa8f8 | 209 | $this->openCiviPage("contact/view", "reset=1&cid=$id&selectedChild=member", "xpath=//div[@class='view-content']/div[3]"); |
210 | $this->assertElementContainsText("xpath=//div[@class='view-content']", 'No memberships have been recorded for this contact.'); | |
6a488035 TO |
211 | |
212 | // visit relationship tab and re-enable the relationship | |
213 | $this->click('css=li#tab_rel a'); | |
214 | $this->waitForElementPresent('css=div.action-link'); | |
215 | $this->click("//li[@id='tab_rel']/a"); | |
9d15e987 | 216 | |
cebea087 | 217 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); |
218 | $this->click("xpath=//div[@class='crm-contact-relationship-past']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); | |
6a488035 TO |
219 | $this->waitForElementPresent('is_active'); |
220 | if (!$this->isChecked('is_active')) { | |
221 | $this->click('is_active'); | |
222 | } | |
223 | $this->click('_qf_Relationship_upload'); | |
cebea087 | 224 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); |
6a488035 | 225 | //check the status message |
6c5f7368 | 226 | $this->waitForText('crm-notification-container', 'Relationship record has been updated.'); |
6a488035 TO |
227 | |
228 | //check for memberships | |
229 | $this->click('css=li#tab_member a'); | |
230 | $this->waitForElementPresent('css=div#memberships'); | |
231 | ||
232 | //2 . visit relationship tab and disable the relationship (by links) | |
233 | //disable relationship | |
234 | $this->click('css=li#tab_rel a'); | |
235 | $this->waitForElementPresent('css=div.action-link'); | |
cebea087 | 236 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); |
237 | $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Disable']"); | |
238 | $this->waitForText("xpath=//div[@class='crm-confirm-dialog ui-dialog-content ui-widget-content modal-dialog']", 'Are you sure you want to disable this relationship?'); | |
239 | $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Yes']"); | |
efb29358 CW |
240 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
241 | // Sleep should never be used for wait for anything to load from the server | |
242 | // Justification for this instance: FIXME | |
6a488035 TO |
243 | sleep(10); |
244 | ||
245 | //verify inherited membership has been removed | |
fc2fa8f8 | 246 | $this->openCiviPage("contact/view", "reset=1&cid={$id}&selectedChild=member", "xpath=//div[@class='view-content']/div[3]"); |
247 | $this->assertElementContainsText("xpath=//div[@class='view-content']/div[3]", 'No memberships have been recorded for this contact.'); | |
6a488035 TO |
248 | |
249 | //enable relationship | |
250 | $this->click('css=li#tab_rel a'); | |
251 | $this->waitForElementPresent('css=div.action-link'); | |
252 | ||
cebea087 | 253 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']"); |
254 | $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span[2][text()='more']/ul/li[1]/a[text()='Enable']"); | |
6a488035 TO |
255 | |
256 | //verify membership | |
257 | $this->click('css=li#tab_member a'); | |
258 | $this->waitForElementPresent('css=div#memberships'); | |
259 | } | |
385f7a49 | 260 | |
261 | /* | |
262 | * Webtest for CRM-10146 | |
263 | * | |
264 | */ | |
265 | function testInheritedMembershipActivity() { | |
266 | // Log in using webtestLogin() method | |
267 | $this->webtestLogin(); | |
268 | ||
269 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); | |
270 | ||
271 | $title = substr(sha1(rand()), 0, 7); | |
272 | $this->type('organization_name', "Organization $title"); | |
273 | $this->type('email_1_email', "$title@org.com"); | |
274 | $this->clickLink('_qf_Contact_upload_view'); | |
275 | $this->waitForText('crm-notification-container', "Organization {$title} has been created."); | |
276 | ||
277 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); | |
278 | ||
279 | $this->click('link=Add Membership Type'); | |
280 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
281 | ||
282 | $this->type('name', "Membership Type $title"); | |
283 | ||
fc2fa8f8 | 284 | $this->select2('member_of_contact_id', $title); |
385f7a49 | 285 | |
286 | $this->type('minimum_fee', '100'); | |
287 | $this->select('financial_type_id', 'label=Member Dues'); | |
288 | $this->type('duration_interval', 1); | |
289 | $this->select('duration_unit', 'label=year'); | |
290 | ||
fc2fa8f8 | 291 | $this->select('period_type', 'value=rolling'); |
385f7a49 | 292 | |
293 | $this->removeSelection('relationship_type_id', 'label=- select -'); | |
294 | $this->addSelection('relationship_type_id', 'label=Employer of'); | |
295 | ||
296 | $this->type('max_related', '5'); | |
297 | ||
298 | $this->click('_qf_MembershipType_upload-bottom'); | |
299 | $this->waitForElementPresent('link=Add Membership Type'); | |
300 | $this->waitForText('crm-notification-container', "Membership Type $title"); | |
301 | ||
c206647d | 302 | // creating another Organization |
385f7a49 | 303 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
304 | $org1 = substr(sha1(rand()), 0, 7); | |
305 | $this->type('organization_name', "Organization $org1"); | |
306 | $this->type('email_1_email', "$org1@org.com"); | |
307 | $this->clickLink('_qf_Contact_upload_view'); | |
308 | ||
309 | // click through to the membership view screen | |
310 | $this->click('css=li#tab_member a'); | |
311 | ||
312 | $this->waitForElementPresent('link=Add Membership'); | |
313 | $this->click('link=Add Membership'); | |
314 | ||
315 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
316 | ||
317 | // fill in Membership Organization and Type | |
318 | $this->select('membership_type_id[0]', "label=Organization $title"); | |
319 | $this->select('membership_type_id[1]', "label=Membership Type $title"); | |
320 | ||
321 | $sourceText = 'Membership ContactAddTest with Rolling Membership Type'; | |
322 | // fill in Source | |
323 | $this->type('source', $sourceText); | |
324 | ||
325 | // Clicking save. | |
fc2fa8f8 | 326 | $this->click('_qf_Membership_upload'); |
385f7a49 | 327 | |
328 | // page was loaded | |
329 | $this->waitForTextPresent($sourceText); | |
330 | ||
331 | // Is status message correct? | |
332 | $this->waitForText('crm-notification-container', "Membership Type $title"); | |
333 | ||
334 | // Adding contact | |
335 | $this->openCiviPage('contact/add', 'reset=1&ct=Individual', '_qf_Contact_cancel-bottom'); | |
336 | $firstName = substr(sha1(rand()), 0, 7); | |
337 | $lastName = 'Anderson'; | |
338 | $email = "$firstName@anderson.name"; | |
339 | $this->type("first_name", $firstName); | |
340 | $this->type("last_name", $lastName); | |
341 | ||
342 | // Set Current Employer | |
fc2fa8f8 | 343 | $this->select2('employer_id', $org1); |
344 | $this->waitForText('s2id_employer_id', $org1); | |
385f7a49 | 345 | |
346 | $this->type("email_1_email", $email); | |
347 | $this->clickLink("_qf_Contact_upload_view-bottom"); | |
348 | $cid = $this->urlArg('cid'); | |
349 | ||
350 | // click through to the membership view screen | |
351 | $this->click('css=li#tab_member a'); | |
352 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
353 | ||
354 | // check number of membership for contact | |
355 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); | |
356 | ||
cebea087 | 357 | $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); |
358 | $expectedMembershipId = $url['queryString']['id']; | |
385f7a49 | 359 | |
360 | // click through to the activity view screen | |
361 | $this->click('css=li#tab_activity a'); | |
cebea087 | 362 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); |
385f7a49 | 363 | |
364 | // check number of activity for contact | |
365 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); | |
366 | ||
cebea087 | 367 | $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']@href")); |
368 | $expectedMembershipActivityId = $url['queryString']['id']; | |
385f7a49 | 369 | |
370 | // verify membership id with membership activity id | |
371 | $this->assertEquals($expectedMembershipId, $expectedMembershipActivityId); | |
372 | ||
373 | // click through to the relationship view screen | |
374 | $this->click('css=li#tab_rel a'); | |
cebea087 | 375 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
376 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org1']")); | |
385f7a49 | 377 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
378 | ||
379 | // Edit Contact but do not change any field | |
27c7ef42 RN |
380 | $this->waitForElementPresent("xpath=//ul[@id='actions']/li[2]/a/span"); |
381 | $this->clickLink("xpath=//ul[@id='actions']/li[2]/a/span"); | |
385f7a49 | 382 | $this->waitForElementPresent('_qf_Contact_cancel-bottom'); |
383 | $this->clickLink("_qf_Contact_upload_view-top"); | |
384 | ||
385 | // click through to the membership view screen after edit | |
386 | $this->click('css=li#tab_member a'); | |
387 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
388 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); | |
cebea087 | 389 | |
390 | $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); | |
391 | $actualMembershipId1 = $url['queryString']['id']; | |
385f7a49 | 392 | |
393 | // click through to the activity view screen after edit | |
394 | $this->click('css=li#tab_activity a'); | |
cebea087 | 395 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); |
385f7a49 | 396 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
cebea087 | 397 | $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']@href")); |
398 | $actualMembershipActivityId1 = $url['queryString']['id']; | |
385f7a49 | 399 | |
400 | // verify membership id and membership activity id with previous one | |
401 | $this->assertEquals($expectedMembershipId, $actualMembershipId1); | |
402 | $this->assertEquals($expectedMembershipId, $actualMembershipActivityId1); | |
403 | ||
404 | // click through to the relationship view screen after edit | |
405 | $this->click('css=li#tab_rel a'); | |
cebea087 | 406 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
407 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org1']")); | |
385f7a49 | 408 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
409 | ||
410 | // change the current employer of the contact | |
411 | // creating another membership type | |
412 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); | |
413 | ||
414 | $this->click('link=Add Membership Type'); | |
415 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); | |
416 | ||
417 | $this->type('name', "Membership Type Another $title"); | |
418 | ||
cebea087 | 419 | $this->select2('member_of_contact_id', $title); |
385f7a49 | 420 | |
421 | $this->type('minimum_fee', '100'); | |
422 | $this->select('financial_type_id', 'label=Member Dues'); | |
423 | $this->type('duration_interval', 1); | |
424 | $this->select('duration_unit', 'label=year'); | |
425 | ||
cebea087 | 426 | $this->select('period_type', 'value=rolling'); |
385f7a49 | 427 | |
428 | $this->removeSelection('relationship_type_id', 'label=- select -'); | |
429 | $this->addSelection('relationship_type_id', 'label=Employer of'); | |
430 | ||
431 | $this->type('max_related', '5'); | |
432 | ||
433 | $this->click('_qf_MembershipType_upload-bottom'); | |
434 | $this->waitForElementPresent('link=Add Membership Type'); | |
435 | $this->waitForText('crm-notification-container', "Membership Type Another $title"); | |
436 | ||
437 | // creating another Orgnization | |
438 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); | |
439 | $org2 = substr(sha1(rand()), 0, 7); | |
440 | $this->type('organization_name', "Organization $org2"); | |
441 | $this->type('email_1_email', "$org2@org.com"); | |
442 | $this->clickLink('_qf_Contact_upload_view'); | |
443 | ||
444 | // click through to the membership view screen | |
445 | $this->click('css=li#tab_member a'); | |
446 | $this->waitForElementPresent('link=Add Membership'); | |
447 | $this->click('link=Add Membership'); | |
448 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); | |
449 | ||
450 | // fill in Membership Organization and Type | |
451 | $this->select('membership_type_id[0]', "label=Organization $title"); | |
452 | $this->select('membership_type_id[1]', "label=Membership Type Another $title"); | |
453 | ||
454 | $sourceText = 'Membership ContactAddTest with Rolling Membership Type'; | |
455 | $this->type('source', $sourceText); | |
cebea087 | 456 | $this->clickLink('_qf_Membership_upload', 'link=Add Membership', FALSE); |
385f7a49 | 457 | $this->waitForTextPresent($sourceText); |
458 | ||
459 | // Is status message correct? | |
460 | $this->waitForText('crm-notification-container', "Membership Type Another $title"); | |
461 | ||
462 | // edit contact | |
463 | $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid", "_qf_Contact_cancel-bottom"); | |
464 | ||
465 | // change Current Employer | |
cebea087 | 466 | $this->select2('employer_id', $org2); |
385f7a49 | 467 | $this->clickLink("_qf_Contact_upload_view-bottom"); |
468 | ||
469 | // click through to the membership view screen | |
470 | $this->click('css=li#tab_member a'); | |
471 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
472 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); | |
cebea087 | 473 | $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); |
474 | $actualMembershipId2 = $url['queryString']['id']; | |
385f7a49 | 475 | |
476 | // click through to the activity view screen | |
477 | $this->click('css=li#tab_activity a'); | |
cebea087 | 478 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); |
385f7a49 | 479 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
cebea087 | 480 | $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']@href")); |
481 | $actualMembershipActivityId2 = $url['queryString']['id']; | |
385f7a49 | 482 | |
483 | // verify membership id and membership activity id with previous one | |
484 | $this->assertNotEquals($expectedMembershipId, $actualMembershipId2); | |
485 | $this->assertNotEquals($expectedMembershipId, $actualMembershipActivityId2); | |
486 | ||
487 | // click through to the relationship view screen | |
488 | $this->click('css=li#tab_rel a'); | |
cebea087 | 489 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
490 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org2']")); | |
385f7a49 | 491 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
492 | ||
493 | // creating another Orgnization with no membership | |
494 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); | |
495 | $org3 = substr(sha1(rand()), 0, 7); | |
496 | $this->type('organization_name', "Organization $org3"); | |
497 | $this->type('email_1_email', "$org3@org.com"); | |
498 | $this->clickLink('_qf_Contact_upload_view'); | |
499 | ||
500 | // edit contact | |
501 | $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid", "_qf_Contact_cancel-bottom"); | |
502 | ||
503 | // change Current Employer | |
cebea087 | 504 | $this->select2('employer_id', $org3); |
385f7a49 | 505 | $this->clickLink("_qf_Contact_upload_view-bottom"); |
506 | ||
507 | // click through to the membership view screen | |
508 | $this->click('css=li#tab_member a'); | |
cebea087 | 509 | |
510 | $this->waitForText("xpath=//div[@class='messages status no-popup']", "No memberships have been recorded for this contact."); | |
385f7a49 | 511 | $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_member']/a/em")); |
512 | ||
513 | // click through to the activity view screen | |
514 | $this->click('css=li#tab_activity a'); | |
cebea087 | 515 | $this->waitForText("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody/tr/td", "No matches found."); |
385f7a49 | 516 | $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
517 | ||
518 | // click through to the relationship view screen | |
519 | $this->click('css=li#tab_rel a'); | |
cebea087 | 520 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
521 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org3']")); | |
385f7a49 | 522 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
523 | } | |
6a488035 TO |
524 | } |
525 |