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