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