Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Member_SeperateMembershipPaymentTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Member_SeperateMembershipPaymentTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testSeperateMembershipCreate() { |
6a488035 TO |
39 | // a random 7-char string and an even number to make this pass unique |
40 | $hash = substr(sha1(rand()), 0, 7); | |
41 | $rand = 2 * rand(2, 50); | |
6a488035 TO |
42 | // Log in using webtestLogin() method |
43 | $this->webtestLogin(); | |
44 | ||
6a488035 TO |
45 | $firstName1 = 'Ma_' . substr(sha1(rand()), 0, 7); |
46 | $lastName1 = 'An_' . substr(sha1(rand()), 0, 7); | |
47 | $this->webtestAddContact($firstName1, $lastName1, TRUE); | |
6c5f7368 | 48 | $this->waitForText('crm-notification-container', "$firstName1 $lastName1 has been created."); |
a471a3b6 | 49 | $cid = $this->urlArg('cid'); |
6a488035 TO |
50 | |
51 | // create contribution page with randomized title and default params | |
52 | $amountSection = TRUE; | |
53 | $payLater = TRUE; | |
54 | $onBehalf = FALSE; | |
55 | $pledges = FALSE; | |
56 | $recurring = FALSE; | |
57 | $memberships = TRUE; | |
58 | $memPriceSetId = NULL; | |
59 | $friend = TRUE; | |
60 | $profilePreId = NULL; | |
61 | $profilePostId = NULL; | |
62 | $premiums = FALSE; | |
63 | $widget = FALSE; | |
64 | $pcp = FALSE; | |
65 | $isAddPaymentProcessor = FALSE; | |
66 | $isSeparatePayment = TRUE; | |
67 | ||
68 | $contributionTitle = "Title $hash"; | |
69 | $pageId = $this->webtestAddContributionPage($hash, | |
70 | $rand, | |
71 | $contributionTitle, | |
72 | NULL, | |
73 | $amountSection, | |
74 | $payLater, | |
75 | $onBehalf, | |
76 | $pledges, | |
77 | $recurring, | |
78 | $memberships, | |
79 | $memPriceSetId, | |
80 | $friend, | |
81 | $profilePreId, | |
82 | $profilePostId, | |
83 | $premiums, | |
84 | $widget, | |
85 | $pcp, | |
86 | $isAddPaymentProcessor, | |
87 | FALSE, | |
88 | $isSeparatePayment, | |
89 | FALSE | |
90 | ); | |
91 | ||
6a488035 TO |
92 | // create new membership types |
93 | $memTypeParams1 = $this->webtestAddMembershipType(); | |
92915c55 TO |
94 | $memTypeTitle1 = $memTypeParams1['membership_type']; |
95 | $memTypeId1 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle1}']/../../td[12]/span/a[3]@href")); | |
96 | $memTypeId1 = $memTypeId1[1]; | |
6a488035 TO |
97 | |
98 | $memTypeParams2 = $this->webtestAddMembershipType(); | |
92915c55 TO |
99 | $memTypeTitle2 = $memTypeParams2['membership_type']; |
100 | $memTypeId2 = explode('&id=', $this->getAttribute("xpath=//div[@id='membership_type']/table/tbody//tr/td/div[text()='{$memTypeTitle2}']/../../td[12]/span/a[3]@href")); | |
101 | $memTypeId2 = $memTypeId2[1]; | |
6a488035 TO |
102 | |
103 | // edit contribution page memberships tab to add two new membership types | |
6317df5c | 104 | $this->openCiviPage('admin/contribute/membership', "reset=1&action=update&id={$pageId}", "_qf_MembershipBlock_next-bottom"); |
6a488035 TO |
105 | $this->click("membership_type_$memTypeId1"); |
106 | $this->click("membership_type_$memTypeId2"); | |
225a8648 | 107 | $this->clickLink('_qf_MembershipBlock_next', '_qf_MembershipBlock_next-bottom'); |
6a488035 | 108 | $text = "'MembershipBlock' information has been saved."; |
6c5f7368 | 109 | $this->waitForText('crm-notification-container', $text); |
6a488035 TO |
110 | $this->_testOnlineMembershipSignup($pageId, $memTypeTitle1, $cid); |
111 | ||
112 | //Find Member | |
6317df5c | 113 | $this->openCiviPage('member/search', 'reset=1', 'member_end_date_high'); |
8fb46c61 | 114 | $this->type("sort_name", "$lastName1 $firstName1"); |
225a8648 | 115 | $this->clickLink("_qf_Search_refresh", "xpath=//div[@id='memberSearch']/table/tbody/tr"); |
6a488035 TO |
116 | $this->click("xpath=//div[@id='memberSearch']/table/tbody/tr/td[11]/span/a[text()='View']"); |
117 | $this->waitForElementPresent("_qf_MembershipView_cancel-bottom"); | |
118 | ||
119 | //View Membership Record | |
120 | $verifyData = array( | |
121 | 'Member' => $firstName1 . ' ' . $lastName1, | |
122 | 'Membership Type' => $memTypeTitle1, | |
123 | 'Status' => 'Pending', | |
124 | 'Source' => 'Online Contribution:' . ' ' . $contributionTitle, | |
125 | ); | |
6317df5c PJ |
126 | |
127 | $this->webtestVerifyTabularData($verifyData); | |
6a488035 TO |
128 | |
129 | // Click View action link on associated contribution record | |
343688b7 RK |
130 | |
131 | $this->waitForElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/div[@class='crm-accordion-wrapper']/div/table/tbody/tr[1]/td[8]/span/a[1][text()='View']"); | |
132 | $this->click("xpath=//form[@id='MembershipView']/div[2]/div/div[@class='crm-accordion-wrapper']/div/table/tbody/tr[1]/td[8]/span/a[1][text()='View']"); | |
133 | $this->waitForElementPresent("xpath=//div[@class='ui-dialog-buttonset']/button[3]/span[2]"); | |
6a488035 TO |
134 | |
135 | //View Contribution Record | |
136 | $verifyData = array( | |
137 | 'From' => $firstName1 . ' ' . $lastName1, | |
138 | 'Total Amount' => '$ 100.00', | |
139 | ); | |
6317df5c PJ |
140 | $this->webtestVerifyTabularData($verifyData); |
141 | ||
6a488035 | 142 | $this->click("_qf_ContributionView_cancel-bottom"); |
343688b7 | 143 | $this->waitForElementPresent("xpath=//form[@id='MembershipView']/div[2]/div/div[@class='crm-accordion-wrapper']/div/table/tbody/tr[1]/td[8]/span/a[1][text()='View']"); |
6a488035 TO |
144 | } |
145 | ||
4cbe18b8 | 146 | /** |
100fef9d CW |
147 | * @param int $pageId |
148 | * @param int $memTypeId | |
149 | * @param int $cid | |
4cbe18b8 | 150 | */ |
00be9182 | 151 | public function _testOnlineMembershipSignup($pageId, $memTypeId, $cid = NULL) { |
6a488035 | 152 | //Open Live Contribution Page |
b45c587e | 153 | $args = array('reset' => 1, 'id' => $pageId); |
6a488035 | 154 | if ($cid) { |
b45c587e | 155 | $args['cid'] = $cid; |
6a488035 | 156 | } |
b45c587e | 157 | $this->openCiviPage("contribute/transact", $args, '_qf_Main_upload-bottom'); |
6a488035 TO |
158 | |
159 | // Select membership type 1 | |
63d14d48 | 160 | $this->click("xpath=//div[@class='crm-section membership_amount-section']/div[2]//div/span/label/span[1][contains(text(),'$memTypeId')]"); |
6a488035 | 161 | $this->type("xpath=//div[@class='crm-section other_amount-section']//div[2]/input", 60); |
b45c587e CW |
162 | $this->clickLink("_qf_Main_upload-bottom", "_qf_Confirm_next-bottom"); |
163 | $this->clickLink("_qf_Confirm_next-bottom", NULL); | |
6a488035 | 164 | } |
96025800 | 165 | |
42daf119 | 166 | } |