3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Member_EditMembershipTest
32 class WebTest_Member_EditMembershipTest
extends CiviSeleniumTestCase
{
33 protected function setUp() {
37 public function testEditMembershipActivityTypes() {
38 // Log in using webtestLogin() method
39 $this->webtestLogin();
41 $firstName = substr(sha1(rand()), 0, 7);
42 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
43 $contactName = "Memberson, {$firstName}";
44 $displayName = "{$firstName} Memberson";
46 // Add new Financial Account
47 $orgName = 'Alberta ' . substr(sha1(rand()), 0, 7);
48 $financialAccountTitle = 'Financial Account ' . substr(sha1(rand()), 0, 4);
49 $financialAccountDescription = "{$financialAccountTitle} Description";
50 $accountingCode = 1033;
51 $financialAccountType = 'Liability';
52 $taxDeductible = TRUE;
58 //Add new organisation
59 $this->webtestAddOrganization($orgName);
61 $this->_testAddFinancialAccount($financialAccountTitle,
62 $financialAccountDescription,
65 $financialAccountType,
73 //Add new Financial Type
74 $financialType['name'] = 'Taxable FinancialType ' . substr(sha1(rand()), 0, 4);
75 $financialType['is_deductible'] = TRUE;
76 $financialType['is_reserved'] = FALSE;
77 $this->addeditFinancialType($financialType);
79 // Assign the created Financial Account $financialAccountTitle to $financialType
80 $this->click("xpath=id('ltype')/div/table/tbody/tr/td[1]/div[text()='$financialType[name]']/../../td[7]/span/a[text()='Accounts']");
81 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()=' Assign Account']");
82 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()=' Assign Account']");
83 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']");
84 $this->select('account_relationship', "label=Sales Tax Account is");
85 $this->select('financial_account_id', "label=" . $financialAccountTitle);
86 $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']");
87 $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()=' Assign Account']");
89 // add membership type
90 $membershipTypes = $this->webtestAddMembershipType('rolling', 1, 'year', 'no', 100, $financialType['name']);
93 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
96 $this->webtestFillAutocomplete($contactName);
98 // fill in Membership Organization
99 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
101 // select membership type
102 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
105 $this->type("source", "Membership StandaloneAddTest Webtest");
107 // Let Join Date and Start Date stay default
108 $this->click("_qf_Membership_upload");
110 //Open related 'Edit Contribution' form
111 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
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 //CRM-17417, Simply open and save edit contribution form to check that tax shouldn't be reapplied
115 $this->clickLink("xpath=//a[@title='Edit Contribution']", "_qf_Contribution_upload", FALSE);
116 $this->click("_qf_Contribution_upload");
117 $this->waitForAjaxContent();
118 $this->assertTrue($this->isTextPresent("$ 110.00"), "Contribution Amount got updated as Sale Tax got reapplied which is wrong");
121 $this->click("css=li#tab_member a");
122 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
123 $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
125 'Membership Type' => $membershipTypes['membership_type'],
127 'Source' => 'Membership StandaloneAddTest Webtest',
129 $this->webtestVerifyTabularData($expected);
131 // now edit and update type and status
132 $this->click("crm-membership-edit-button-top");
133 $this->waitForElementPresent("_qf_Membership_upload-bottom");
134 $this->click('is_override');
135 $this->waitForElementPresent('status_id');
136 $this->select('status_id', 'label=Current');
137 $this->select('membership_type_id[0]', 'value=1');
138 $this->select('membership_type_id[1]', 'value=1');
139 $this->click('_qf_Membership_upload-bottom');
141 $this->waitForElementPresent("access");
143 // Use activity search to find the expected activities
144 $this->openCiviPage('activity/search', 'reset=1', "_qf_Search_refresh");
146 $this->type("sort_name", $contactName);
147 $this->select('activity_type_id', 'value=35');
148 $this->select('activity_type_id', 'value=36');
149 $this->clickLink("_qf_Search_refresh");
151 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[2][text()='Change Membership Type']"));
152 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[3][text()='Type changed from {$membershipTypes['membership_type']} to General']"));
153 $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[5]/a[text()='{$contactName}']"));