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_StandaloneAddTest
32 class WebTest_Member_StandaloneAddTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testStandaloneMemberAdd() {
40 $this->webtestLogin();
43 $firstName = substr(sha1(rand()), 0, 7);
44 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
45 $contactName = "Memberson, $firstName";
47 // add membership type
48 $membershipTypes = $this->webtestAddMembershipType();
51 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
54 $this->webtestFillAutocomplete($firstName);
56 // fill in Membership Organization
57 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
59 // select membership type
60 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
63 $this->type("source", "Membership StandaloneAddTest Webtest");
65 // Let Join Date stay default
68 $this->webtestFillDate('start_date');
70 // Let End Date be auto computed
72 // fill in Status Override?
73 // fill in Record Membership Payment?
74 $this->click("send_receipt");
75 $this->assertTrue($this->isChecked("send_receipt"), 'Send Confirmation and Receipt checkbox should be checked.');
76 $this->click("_qf_Membership_upload");
79 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
80 $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
81 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
84 'Membership Type' => $membershipTypes['membership_type'],
86 'Source' => 'Membership StandaloneAddTest Webtest',
88 $this->webtestVerifyTabularData($expected);
91 public function testStandaloneGiftMembership() {
93 $this->webtestLogin();
96 $firstName = substr(sha1(rand()), 0, 7);
97 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
98 $contactName = "Memberson, $firstName";
100 $giftMemberfirstName = substr(sha1(rand()), 0, 7);
101 $this->webtestAddContact($giftMemberfirstName, "Memberson", "Memberson{$giftMemberfirstName}@memberson.name");
102 $giftMembercontactName = "Memberson, $giftMemberfirstName";
104 // add membership type
105 $membershipTypes = $this->webtestAddMembershipType();
107 // now add membership
108 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
111 $this->webtestFillAutocomplete($firstName);
113 // fill in Membership Organization
114 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
116 // select membership type
117 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
120 $this->type("source", "Membership StandaloneAddTest Webtest");
122 // fill in Start Date
123 $this->webtestFillDate('start_date');
125 // add softcredit details
127 $financialType = 'Donation';
128 $this->clickLink('is_different_contribution_contact', 'total_amount', FALSE);
130 $this->select('soft_credit_type_id', 'Gift');
131 $this->select2('soft_credit_contact_id', $giftMembercontactName);
132 $this->select('financial_type_id', 'Donation');
133 $this->type('total_amount', $totalAmount);
134 $this->select('payment_instrument_id', 'Check');
135 $this->select('contribution_status_id', 'Completed');
137 $this->click("_qf_Membership_upload");
140 $this->waitForElementPresent("xpath=//table[@class='display dataTable no-footer']/tbody/tr[1]/td[9]/span/a[text()='View']");
141 $this->click("xpath=xpath=//table[@class='display dataTable no-footer']/tbody/tr[1]/td[9]/span/a[text()='View']");
142 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
144 // verify soft credit data
146 '1' => $giftMemberfirstName . ' Memberson',
153 foreach ($expected as $key => $value) {
154 $this->verifyText("xpath=//div[@class='crm-accordion-wrapper']//table/tbody//tr/td[$key]", $value);
159 public function testStandaloneMemberOverrideAdd() {
161 $this->webtestLogin();
164 $firstName = substr(sha1(rand()), 0, 7);
165 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
166 $contactName = "Memberson, $firstName";
168 // add membership type
169 $membershipTypes = $this->webtestAddMembershipType();
172 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
175 $this->webtestFillAutocomplete($firstName);
177 // fill in Membership Organization
178 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
180 // select membership type
181 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
184 $this->type("source", "Membership StandaloneAddTest Webtest");
186 // Let Join Date stay default
188 // fill in Start Date
189 $this->webtestFillDate('start_date');
191 // Let End Date be auto computed
193 // fill in Status Override?
194 $this->click("is_override", "value=1");
195 $this->waitForElementPresent("status_id");
196 $this->select("status_id", "value=3");
198 // fill in Record Membership Payment?
199 $this->click("record_contribution", "value=1");
200 $this->waitForElementPresent("contribution_status_id");
201 // let financial type be default
203 // let the amount be default
205 // select payment instrument type = Check and enter chk number
206 $this->select("payment_instrument_id", "value=4");
207 $this->waitForElementPresent("check_number");
208 $this->type("check_number", "check #12345");
209 $this->type("trxn_id", "P5476785" . rand(100, 10000));
211 // fill the payment status be default
212 $this->select("contribution_status_id", "value=2");
217 $this->click("_qf_Membership_upload");
218 $this->waitForPageToLoad($this->getTimeoutMsec());
221 $this->waitForTextPresent("Membership StandaloneAddTest Webtest");
223 // verify if Membership is created
224 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
226 //click through to the Membership view screen
227 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
228 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
231 'Membership Type' => $membershipTypes['membership_type'],
233 'Source' => 'Membership StandaloneAddTest Webtest',
235 $this->webtestVerifyTabularData($expected);
238 public function testAjaxCustomGroupLoad() {
239 $this->webtestLogin();
240 $triggerElement = array('name' => 'membership_type_id_1', 'type' => 'select');
242 array('entity' => 'Membership', 'subEntity' => 'General', 'triggerElement' => $triggerElement),
243 array('entity' => 'Membership', 'subEntity' => 'Student', 'triggerElement' => $triggerElement),
246 $pageUrl = array('url' => 'member/add', 'args' => 'reset=1&action=add&context=standalone');
248 //case where we should fire certain
249 //ui actions which helps triggering possible
251 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl,
252 function () use ($test) {
253 $test->select('membership_type_id_0', 'value=1');