| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
| 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 | //$this->markTestSkipped('Skipping for now as it works fine locally.'); |
| 39 | // Log in using webtestLogin() method |
| 40 | $this->webtestLogin(); |
| 41 | |
| 42 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
| 43 | |
| 44 | $title = substr(sha1(rand()), 0, 7); |
| 45 | $this->type('organization_name', "Organization $title"); |
| 46 | $this->type('email_1_email', "$title@org.com"); |
| 47 | $this->click('_qf_Contact_upload_view'); |
| 48 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 49 | $this->waitForText('crm-notification-container', "Organization {$title} has been created."); |
| 50 | |
| 51 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); |
| 52 | |
| 53 | $this->click('link=Add Membership Type'); |
| 54 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); |
| 55 | |
| 56 | $this->type('name', "Membership Type $title"); |
| 57 | |
| 58 | $this->select2('member_of_contact_id', $title); |
| 59 | |
| 60 | $this->type('minimum_fee', '100'); |
| 61 | $this->select('financial_type_id', 'value=2'); |
| 62 | $this->type('duration_interval', 1); |
| 63 | $this->select('duration_unit', 'label=year'); |
| 64 | |
| 65 | $this->select('period_type', 'value=rolling'); |
| 66 | |
| 67 | $this->removeSelection('relationship_type_id', 'label=- select -'); |
| 68 | $this->addSelection('relationship_type_id', 'label=Employer of'); |
| 69 | |
| 70 | $this->type('max_related', '5'); |
| 71 | |
| 72 | $this->click('_qf_MembershipType_upload-bottom'); |
| 73 | $this->waitForElementPresent('link=Add Membership Type'); |
| 74 | $this->waitForText('crm-notification-container', "Membership Type $title"); |
| 75 | |
| 76 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
| 77 | |
| 78 | // creating another Orgnization |
| 79 | $title1 = substr(sha1(rand()), 0, 7); |
| 80 | $this->type('organization_name', "Organization $title1"); |
| 81 | $this->type('email_1_email', "$title1@org.com"); |
| 82 | $this->click('_qf_Contact_upload_view'); |
| 83 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
| 84 | |
| 85 | // click through to the membership view screen |
| 86 | $this->click('css=li#tab_member a'); |
| 87 | |
| 88 | $this->waitForElementPresent('link=Add Membership'); |
| 89 | $this->click('link=Add Membership'); |
| 90 | |
| 91 | $this->waitForElementPresent('_qf_Membership_cancel-bottom'); |
| 92 | |
| 93 | // fill in Membership Organization and Type |
| 94 | $this->select('membership_type_id[0]', "label=Organization $title"); |
| 95 | $this->select('membership_type_id[1]', "label=Membership Type $title"); |
| 96 | |
| 97 | $sourceText = 'Membership ContactAddTest with Fixed Membership Type'; |
| 98 | // fill in Source |
| 99 | $this->type('source', $sourceText); |
| 100 | |
| 101 | // Clicking save. |
| 102 | $this->click('_qf_Membership_upload'); |
| 103 | $this->waitForElementPresent('link=Add Membership'); |
| 104 | |
| 105 | // page was loaded |
| 106 | $this->waitForTextPresent($sourceText); |
| 107 | |
| 108 | // Is status message correct? |
| 109 | $this->waitForText('crm-notification-container', "Membership Type $title"); |
| 110 | |
| 111 | // click through to the membership view screen |
| 112 | $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); |
| 113 | $this->waitForElementPresent('_qf_MembershipView_cancel-bottom'); |
| 114 | |
| 115 | $joinDate = date('Y-m-d'); |
| 116 | $startDate = date('Y-m-d'); |
| 117 | $endDate = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y') + 1)); |
| 118 | foreach (array( |
| 119 | 'joinDate', |
| 120 | 'startDate', |
| 121 | 'endDate', |
| 122 | ) as $date) { |
| 123 | $$date = CRM_Utils_Date::customFormat($$date, $this->webtestGetSetting('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(1, $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(1, $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 | // FIXME: These 2 lines are currently failing because the inherited membership and signup activity or being recreated when contact is edited/saved. dgg |
| 403 | $this->assertEquals($expectedMembershipId, $actualMembershipId1); |
| 404 | $this->assertEquals($expectedMembershipActivityId, $actualMembershipActivityId1); |
| 405 | |
| 406 | // click through to the relationship view screen after edit |
| 407 | $this->click('css=li#tab_rel a'); |
| 408 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
| 409 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org1']")); |
| 410 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
| 411 | |
| 412 | // change the current employer of the contact |
| 413 | // creating another membership type |
| 414 | $this->openCiviPage('admin/member/membershipType', 'reset=1&action=browse'); |
| 415 | |
| 416 | $this->click('link=Add Membership Type'); |
| 417 | $this->waitForElementPresent('_qf_MembershipType_cancel-bottom'); |
| 418 | |
| 419 | $this->type('name', "Membership Type Another $title"); |
| 420 | |
| 421 | $this->select2('member_of_contact_id', $title); |
| 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', 'value=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', 'link=Add Membership', FALSE); |
| 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->select2('employer_id', $org2); |
| 469 | $this->clickLink("_qf_Contact_upload_view-bottom"); |
| 470 | |
| 471 | // click through to the membership view screen |
| 472 | $this->click('css=li#tab_member a'); |
| 473 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); |
| 474 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_member']/a/em")); |
| 475 | $url = $this->parseURL($this->getAttribute("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']@href")); |
| 476 | $actualMembershipId2 = $url['queryString']['id']; |
| 477 | |
| 478 | // click through to the activity view screen |
| 479 | $this->click('css=li#tab_activity a'); |
| 480 | $this->waitForElementPresent("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']"); |
| 481 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
| 482 | $url = $this->parseURL($this->getAttribute("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody//tr/td[8]/span/a[text()='View']@href")); |
| 483 | $actualMembershipActivityId2 = $url['queryString']['id']; |
| 484 | |
| 485 | // verify membership id and membership activity id with previous one |
| 486 | $this->assertNotEquals($expectedMembershipId, $actualMembershipId2); |
| 487 | $this->assertNotEquals($expectedMembershipId, $actualMembershipActivityId2); |
| 488 | |
| 489 | // click through to the relationship view screen |
| 490 | $this->click('css=li#tab_rel a'); |
| 491 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
| 492 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org2']")); |
| 493 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
| 494 | |
| 495 | // creating another Orgnization with no membership |
| 496 | $this->openCiviPage('contact/add', 'reset=1&ct=Organization', '_qf_Contact_cancel'); |
| 497 | $org3 = substr(sha1(rand()), 0, 7); |
| 498 | $this->type('organization_name', "Organization $org3"); |
| 499 | $this->type('email_1_email', "$org3@org.com"); |
| 500 | $this->clickLink('_qf_Contact_upload_view'); |
| 501 | |
| 502 | // edit contact |
| 503 | $this->openCiviPage("contact/add", "reset=1&action=update&cid=$cid", "_qf_Contact_cancel-bottom"); |
| 504 | |
| 505 | // change Current Employer |
| 506 | $this->select2('employer_id', $org3); |
| 507 | $this->clickLink("_qf_Contact_upload_view-bottom"); |
| 508 | |
| 509 | // click through to the membership view screen |
| 510 | $this->click('css=li#tab_member a'); |
| 511 | |
| 512 | $this->waitForAjaxContent(); |
| 513 | $this->waitForTextPresent("No memberships have been recorded for this contact."); |
| 514 | $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_member']/a/em")); |
| 515 | |
| 516 | // click through to the activity view screen |
| 517 | $this->click('css=li#tab_activity a'); |
| 518 | $this->waitForText("xpath=//table[@class='contact-activity-selector-activity dataTable no-footer']/tbody/tr/td", "No matches found."); |
| 519 | $this->assertEquals(0, $this->getText("xpath=//li[@id='tab_activity']/a/em")); |
| 520 | |
| 521 | // click through to the relationship view screen |
| 522 | $this->click('css=li#tab_rel a'); |
| 523 | $this->waitForElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a"); |
| 524 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-contact-relationship-current']/div/table/tbody/tr/td[2]/a[text()='Organization $org3']")); |
| 525 | $this->assertEquals(1, $this->getText("xpath=//li[@id='tab_rel']/a/em")); |
| 526 | } |
| 527 | |
| 528 | } |