| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.6 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
| 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 | |
| 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
| 28 | |
| 29 | /** |
| 30 | * Class WebTest_Member_InheritedMembershipTest |
| 31 | */ |
| 32 | class WebTest_Member_InheritedMembershipTest extends CiviSeleniumTestCase { |
| 33 | protected function setUp() { |
| 34 | parent::setUp(); |
| 35 | } |
| 36 | |
| 37 | public function testInheritedMembership() { |
| 38 | // Log in using webtestLogin() method |
| 39 | $this->webtestLogin(); |
| 40 | |
| 41 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
| 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()); |
| 48 | $this->waitForText('crm-notification-container', "Organization {$title} has been created."); |
| 49 | |
| 50 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); |
| 51 | |
| 52 | $this->click('link=Add Membership Type'); |
| 53 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); |
| 54 | |
| 55 | $this->type('name', "Membership Type $title"); |
| 56 | |
| 57 | $this->select2('member_of_contact_id', $title); |
| 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 | |
| 64 | $this->select('period_type', 'value=rolling'); |
| 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'); |
| 73 | $this->waitForText('crm-notification-container', "Membership Type $title"); |
| 74 | |
| 75 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
| 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'); |
| 102 | $this->waitForElementPresent('link=Add Membership'); |
| 103 | |
| 104 | // page was loaded |
| 105 | $this->waitForTextPresent($sourceText); |
| 106 | |
| 107 | // Is status message correct? |
| 108 | $this->waitForText('crm-notification-container', "Membership Type $title"); |
| 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', |
| 120 | 'startDate', |
| 121 | 'endDate', |
| 122 | ) as $date) { |
| 123 | $$date = CRM_Utils_Date::customFormat($$date, $configVars->dateformatFull); |
| 124 | } |
| 125 | |
| 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, |
| 134 | 'Max related' => "5", |
| 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'); |
| 146 | $this->click("//div[@class='action-link']/a/span"); |
| 147 | $this->waitForElementPresent('_qf_Relationship_cancel-bottom'); |
| 148 | $this->click('relationship_type_id'); |
| 149 | $this->select('relationship_type_id', 'label=Employee of'); |
| 150 | |
| 151 | $this->select2('related_contact_id', $title1, TRUE); |
| 152 | |
| 153 | $description = 'Well here is some description !!!!'; |
| 154 | $this->type('description', $description); |
| 155 | |
| 156 | //save the relationship |
| 157 | $this->click('_qf_Relationship_upload-bottom'); |
| 158 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); |
| 159 | //check the status message |
| 160 | $this->waitForText('crm-notification-container', 'Relationship created.'); |
| 161 | |
| 162 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='View']"); |
| 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"); |
| 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")); |
| 192 | $id = explode('&', $id[0]); |
| 193 | $id = explode('=', $id[2]); |
| 194 | $id = $id[1]; |
| 195 | $this->click("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody//tr/td[9]/span/a[text()='Edit']"); |
| 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'); |
| 203 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); |
| 204 | //check the status message |
| 205 | $this->waitForText('crm-notification-container', 'Relationship record has been updated'); |
| 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 |
| 211 | $this->openCiviPage("contact/view", "reset=1&cid=$id&selectedChild=member", "xpath=//div[@class='view-content']/div[3]"); |
| 212 | $this->waitForTextPresent("No memberships have been recorded for this contact."); |
| 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"); |
| 218 | |
| 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']"); |
| 221 | $this->waitForElementPresent('is_active'); |
| 222 | if (!$this->isChecked('is_active')) { |
| 223 | $this->click('is_active'); |
| 224 | } |
| 225 | $this->click('_qf_Relationship_upload'); |
| 226 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']"); |
| 227 | //check the status message |
| 228 | $this->waitForText('crm-notification-container', 'Relationship record has been updated.'); |
| 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'); |
| 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']"); |
| 240 | $this->waitForTextPresent('Are you sure you want to disable this relationship?'); |
| 241 | $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Yes']"); |
| 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 |
| 245 | sleep(10); |
| 246 | |
| 247 | //verify inherited membership has been removed |
| 248 | $this->openCiviPage("contact/view", "reset=1&cid={$id}&selectedChild=member", "xpath=//div[@class='view-content']/div[3]"); |
| 249 | $this->waitForTextPresent("No memberships have been recorded for this contact."); |
| 250 | |
| 251 | //enable relationship |
| 252 | $this->click('css=li#tab_rel a'); |
| 253 | $this->waitForElementPresent('css=div.action-link'); |
| 254 | |
| 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']"); |
| 257 | |
| 258 | //verify membership |
| 259 | $this->click('css=li#tab_member a'); |
| 260 | $this->waitForTextPresent("No memberships have been recorded for this contact."); |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * Webtest for CRM-10146 |
| 265 | */ |
| 266 | public function testInheritedMembershipActivity() { |
| 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 | |
| 285 | $this->select2('member_of_contact_id', $title); |
| 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 | |
| 292 | $this->select('period_type', 'value=rolling'); |
| 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 | |
| 303 | // creating another Organization |
| 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. |
| 327 | $this->click('_qf_Membership_upload'); |
| 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 |
| 344 | $this->select2('employer_id', $org1); |
| 345 | $this->waitForText('s2id_employer_id', $org1); |
| 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 | |
| 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']; |
| 360 | |
| 361 | // click through to the activity view screen |
| 362 | $this->click('css=li#tab_activity a'); |
| 363 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); |
| 364 | |
| 365 | // check number of activity for contact |
| 366 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
| 367 | |
| 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']; |
| 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'); |
| 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']")); |
| 378 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
| 379 | |
| 380 | // Edit Contact but do not change any field |
| 381 | $this->waitForElementPresent("xpath=//ul[@id='actions']/li[2]/a/span"); |
| 382 | $this->clickLink("xpath=//ul[@id='actions']/li[2]/a/span"); |
| 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']"); |
| 389 | $this->assertEquals(2, $this->getText("xpath=//li[@id='tab_member']/a/em")); |
| 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']; |
| 393 | |
| 394 | // click through to the activity view screen after edit |
| 395 | $this->click('css=li#tab_activity a'); |
| 396 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); |
| 397 | $this->assertEquals(2, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
| 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']; |
| 400 | |
| 401 | // verify membership id and membership activity id with previous one |
| 402 | $this->assertEquals($expectedMembershipId, $actualMembershipId1); |
| 403 | $this->assertNotEquals($expectedMembershipId, $actualMembershipActivityId1); |
| 404 | |
| 405 | // click through to the relationship view screen after edit |
| 406 | $this->click('css=li#tab_rel a'); |
| 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']")); |
| 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 | |
| 420 | $this->select2('member_of_contact_id', $title); |
| 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 | |
| 427 | $this->select('period_type', 'value=rolling'); |
| 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); |
| 457 | $this->clickLink('_qf_Membership_upload', 'link=Add Membership', FALSE); |
| 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 |
| 467 | $this->select2('employer_id', $org2); |
| 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")); |
| 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']; |
| 476 | |
| 477 | // click through to the activity view screen |
| 478 | $this->click('css=li#tab_activity a'); |
| 479 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); |
| 480 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
| 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']; |
| 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'); |
| 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']")); |
| 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 |
| 505 | $this->select2('employer_id', $org3); |
| 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'); |
| 510 | |
| 511 | $this->waitForAjaxContent(); |
| 512 | $this->waitForTextPresent("No memberships have been recorded for this contact."); |
| 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'); |
| 517 | $this->waitForText("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody/tr/td", "No matches found."); |
| 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'); |
| 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']")); |
| 524 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
| 525 | } |
| 526 | |
| 527 | } |