| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.5 | |
| 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_EditMembershipTest |
| 31 | */ |
| 32 | class WebTest_Member_EditMembershipTest extends CiviSeleniumTestCase { |
| 33 | protected function setUp() { |
| 34 | parent::setUp(); |
| 35 | } |
| 36 | |
| 37 | function testEditMembershipActivityTypes() { |
| 38 | // Log in using webtestLogin() method |
| 39 | $this->webtestLogin(); |
| 40 | // create contact |
| 41 | $firstName = substr(sha1(rand()), 0, 7); |
| 42 | $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name"); |
| 43 | $contactName = "Memberson, {$firstName}"; |
| 44 | $displayName = "{$firstName} Memberson"; |
| 45 | |
| 46 | // add membership type |
| 47 | $membershipTypes = $this->webtestAddMembershipType(); |
| 48 | |
| 49 | // now add membership |
| 50 | $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload"); |
| 51 | |
| 52 | // select contact |
| 53 | $this->webtestFillAutocomplete($contactName); |
| 54 | |
| 55 | // fill in Membership Organization |
| 56 | $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}"); |
| 57 | |
| 58 | // select membership type |
| 59 | $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}"); |
| 60 | |
| 61 | // fill in Source |
| 62 | $this->type("source", "Membership StandaloneAddTest Webtest"); |
| 63 | |
| 64 | // Let Join Date and Start Date stay default |
| 65 | $this->click("_qf_Membership_upload"); |
| 66 | |
| 67 | //View Membership |
| 68 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); |
| 69 | $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']"); |
| 70 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); |
| 71 | $expected = array( |
| 72 | 'Membership Type' => $membershipTypes['membership_type'], |
| 73 | 'Status' => 'New', |
| 74 | 'Source' => 'Membership StandaloneAddTest Webtest', |
| 75 | ); |
| 76 | $this->webtestVerifyTabularData($expected); |
| 77 | |
| 78 | // now edit and update type and status |
| 79 | $this->click("crm-membership-edit-button-top"); |
| 80 | $this->waitForElementPresent("_qf_Membership_upload-bottom"); |
| 81 | $this->click('is_override'); |
| 82 | $this->waitForElementPresent('status_id'); |
| 83 | $this->select('status_id', 'label=Current'); |
| 84 | $this->select('membership_type_id[0]', 'value=1'); |
| 85 | $this->select('membership_type_id[1]', 'value=1'); |
| 86 | $this->click('_qf_Membership_upload-bottom'); |
| 87 | |
| 88 | $this->waitForElementPresent("access"); |
| 89 | |
| 90 | // Use activity search to find the expected activities |
| 91 | $this->openCiviPage('activity/search', 'reset=1', "_qf_Search_refresh"); |
| 92 | |
| 93 | $this->type("sort_name", $contactName); |
| 94 | $this->click('activity_type_id[35]'); |
| 95 | $this->click('activity_type_id[36]'); |
| 96 | $this->clickLink("_qf_Search_refresh"); |
| 97 | |
| 98 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[2][text()='Change Membership Status']")); |
| 99 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[3][text()='Status changed from New to Current']")); |
| 100 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[5]/a[text()='{$contactName}']")); |
| 101 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[2][text()='Change Membership Type']")); |
| 102 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[3][text()='Type changed from {$membershipTypes['membership_type']} to General']")); |
| 103 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[3]/td[5]/a[text()='{$contactName}']")); |
| 104 | } |
| 105 | } |