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