Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
9d15e987 | 2 | /* |
6a488035 | 3 | +--------------------------------------------------------------------+ |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
15a4309a | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
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_EditMembershipTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_EditMembershipTest extends CiviSeleniumTestCase { |
33 | protected function setUp() { | |
34 | parent::setUp(); | |
35 | } | |
36 | ||
00be9182 | 37 | public function testEditMembershipActivityTypes() { |
6a488035 TO |
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 | ||
7a731220 | 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; | |
53 | $isActive = FALSE; | |
54 | $isTax = TRUE; | |
55 | $taxRate = 10.00; | |
56 | $isDefault = FALSE; | |
57 | ||
58 | //Add new organisation | |
59 | $this->webtestAddOrganization($orgName); | |
60 | ||
61 | $this->_testAddFinancialAccount($financialAccountTitle, | |
62 | $financialAccountDescription, | |
63 | $accountingCode, | |
64 | $orgName, | |
65 | $financialAccountType, | |
66 | $taxDeductible, | |
67 | $isActive, | |
68 | $isTax, | |
69 | $taxRate, | |
70 | $isDefault | |
71 | ); | |
72 | ||
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); | |
78 | ||
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']"); | |
33c81040 WA |
81 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']//button/span[contains(text(), 'Assign Account')]"); |
82 | $this->click("xpath=//div[@class='ui-dialog-buttonset']//button/span[contains(text(), 'Assign Account')]"); | |
7a731220 | 83 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']"); |
84 | $this->select('account_relationship', "label=Sales Tax Account is"); | |
33c81040 | 85 | $this->waitForAjaxContent(); |
7a731220 | 86 | $this->select('financial_account_id', "label=" . $financialAccountTitle); |
87 | $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']"); | |
33c81040 | 88 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']//button/span[contains(text(), 'Assign Account')]"); |
7a731220 | 89 | |
6a488035 | 90 | // add membership type |
7a731220 | 91 | $membershipTypes = $this->webtestAddMembershipType('rolling', 1, 'year', 'no', 100, $financialType['name']); |
6a488035 TO |
92 | |
93 | // now add membership | |
9d15e987 | 94 | $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload"); |
6a488035 TO |
95 | |
96 | // select contact | |
97 | $this->webtestFillAutocomplete($contactName); | |
98 | ||
99 | // fill in Membership Organization | |
100 | $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}"); | |
101 | ||
102 | // select membership type | |
103 | $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}"); | |
104 | ||
105 | // fill in Source | |
106 | $this->type("source", "Membership StandaloneAddTest Webtest"); | |
107 | ||
108 | // Let Join Date and Start Date stay default | |
109 | $this->click("_qf_Membership_upload"); | |
110 | ||
7a731220 | 111 | //Open related 'Edit Contribution' form |
6a488035 TO |
112 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); |
113 | $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']"); | |
114 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
7a731220 | 115 | //CRM-17417, Simply open and save edit contribution form to check that tax shouldn't be reapplied |
116 | $this->clickLink("xpath=//a[@title='Edit Contribution']", "_qf_Contribution_upload", FALSE); | |
117 | $this->click("_qf_Contribution_upload"); | |
118 | $this->waitForAjaxContent(); | |
119 | $this->assertTrue($this->isTextPresent("$ 110.00"), "Contribution Amount got updated as Sale Tax got reapplied which is wrong"); | |
120 | ||
121 | //View Membership | |
122 | $this->click("css=li#tab_member a"); | |
123 | $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']"); | |
124 | $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']"); | |
6a488035 | 125 | $expected = array( |
92915c55 | 126 | 'Membership Type' => $membershipTypes['membership_type'], |
9d15e987 PJ |
127 | 'Status' => 'New', |
128 | 'Source' => 'Membership StandaloneAddTest Webtest', | |
6a488035 | 129 | ); |
9d15e987 | 130 | $this->webtestVerifyTabularData($expected); |
6a488035 TO |
131 | |
132 | // now edit and update type and status | |
133 | $this->click("crm-membership-edit-button-top"); | |
134 | $this->waitForElementPresent("_qf_Membership_upload-bottom"); | |
135 | $this->click('is_override'); | |
136 | $this->waitForElementPresent('status_id'); | |
137 | $this->select('status_id', 'label=Current'); | |
e87cf20c | 138 | $this->select('membership_type_id[0]', 'value=1'); |
139 | $this->select('membership_type_id[1]', 'value=1'); | |
6a488035 TO |
140 | $this->click('_qf_Membership_upload-bottom'); |
141 | ||
142 | $this->waitForElementPresent("access"); | |
143 | ||
144 | // Use activity search to find the expected activities | |
9d15e987 PJ |
145 | $this->openCiviPage('activity/search', 'reset=1', "_qf_Search_refresh"); |
146 | ||
6a488035 | 147 | $this->type("sort_name", $contactName); |
e0f528d0 | 148 | $this->select('activity_type_id', 'value=35'); |
149 | $this->select('activity_type_id', 'value=36'); | |
c3ad8633 | 150 | $this->clickLink("_qf_Search_refresh"); |
6a488035 | 151 | |
e0f528d0 | 152 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[2][text()='Change Membership Type']")); |
153 | $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']")); | |
6a488035 | 154 | $this->assertTrue($this->isElementPresent("xpath=//div[@class='crm-search-results']/table/tbody/tr[2]/td[5]/a[text()='{$contactName}']")); |
6a488035 | 155 | } |
96025800 | 156 | |
42daf119 | 157 | } |