Merge pull request #2909 from jake-mw/crm-14472
[civicrm-core.git] / tests / phpunit / WebTest / Member / StandaloneAddTest.php
CommitLineData
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
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class WebTest_Member_StandaloneAddTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testStandaloneMemberAdd() {
35
6a488035
TO
36 $this->webtestLogin();
37
38 // create contact
39 $firstName = substr(sha1(rand()), 0, 7);
40 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
41 $contactName = "Memberson, $firstName";
42
43 // add membership type
44 $membershipTypes = $this->webtestAddMembershipType();
45
46 // now add membership
69369531 47 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
6a488035
TO
48
49 // select contact
50 $this->webtestFillAutocomplete($firstName);
51
52 // fill in Membership Organization
53 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
54
55 // select membership type
56 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
57
58 // fill in Source
59 $this->type("source", "Membership StandaloneAddTest Webtest");
60
61 // Let Join Date stay default
62
63 // fill in Start Date
64 $this->webtestFillDate('start_date');
65
66 // Let End Date be auto computed
67
68 // fill in Status Override?
69 // fill in Record Membership Payment?
70
71 $this->click("_qf_Membership_upload");
72
73 //View Membership
74 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
75 $this->click("xpath=//div[@id='memberships']//table/tbody/tr[1]/td[9]/span/a[text()='View']");
76 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
69369531 77
6a488035 78 $expected = array(
69369531
RN
79 'Membership Type' => $membershipTypes['membership_type'],
80 'Status' => 'New',
81 'Source' => 'Membership StandaloneAddTest Webtest',
6a488035 82 );
69369531 83 $this->webtestVerifyTabularData($expected);
6a488035
TO
84 }
85
86 function testStandaloneMemberOverrideAdd() {
87
6a488035
TO
88 $this->webtestLogin();
89
90 // add contact
91 $firstName = substr(sha1(rand()), 0, 7);
92 $this->webtestAddContact($firstName, "Memberson", "Memberson{$firstName}@memberson.name");
93 $contactName = "Memberson, $firstName";
94
95 // add membership type
96 $membershipTypes = $this->webtestAddMembershipType();
97
98 // add membership
69369531 99 $this->openCiviPage("member/add", "reset=1&action=add&context=standalone", "_qf_Membership_upload");
6a488035
TO
100
101 // select contact
102 $this->webtestFillAutocomplete($firstName);
103
104 // fill in Membership Organization
105 $this->select("membership_type_id[0]", "label={$membershipTypes['member_of_contact']}");
106
107 // select membership type
108 $this->select("membership_type_id[1]", "label={$membershipTypes['membership_type']}");
109
110 // fill in Source
111 $this->type("source", "Membership StandaloneAddTest Webtest");
112
113 // Let Join Date stay default
114
115 // fill in Start Date
116 $this->webtestFillDate('start_date');
117
118 // Let End Date be auto computed
119
120 // fill in Status Override?
121 $this->click("is_override", "value=1");
122 $this->waitForElementPresent("status_id");
123 $this->select("status_id", "value=3");
124
125 // fill in Record Membership Payment?
126 $this->click("record_contribution", "value=1");
127 $this->waitForElementPresent("contribution_status_id");
128 // let financial type be default
129
130 // let the amount be default
131
132 // select payment instrument type = Check and enter chk number
133 $this->select("payment_instrument_id", "value=4");
134 $this->waitForElementPresent("check_number");
135 $this->type("check_number", "check #12345");
136 $this->type("trxn_id", "P5476785" . rand(100, 10000));
137
138 // fill the payment status be default
139 $this->select("contribution_status_id", "value=2");
140
141 //----
142
143 // Clicking save.
144 $this->click("_qf_Membership_upload");
145 $this->waitForPageToLoad($this->getTimeoutMsec());
146
147 // page was loaded
148 $this->waitForTextPresent("Membership StandaloneAddTest Webtest");
149
150 // verify if Membership is created
151 $this->waitForElementPresent("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
152
153 //click through to the Membership view screen
154 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
155 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
156
157 $expected = array(
69369531
RN
158 'Membership Type' => $membershipTypes['membership_type'],
159 'Status' => 'Grace',
160 'Source' => 'Membership StandaloneAddTest Webtest',
6a488035 161 );
69369531 162 $this->webtestVerifyTabularData($expected);
6a488035 163 }
6a488035 164
c4e6d4e8
PJ
165 function testAjaxCustomGroupLoad() {
166 $this->webtestLogin();
167 $triggerElement = array('name' => 'membership_type_id_1', 'type' => 'select');
168 $customSets = array(
169 array('entity' => 'Membership', 'subEntity' => 'General', 'triggerElement' => $triggerElement),
170 array('entity' => 'Membership', 'subEntity' => 'Student', 'triggerElement' => $triggerElement)
171 );
172
173 $pageUrl = array('url' => 'member/add', 'args' => 'reset=1&action=add&context=standalone');
5b8ddc60
PJ
174
175 //case where we should fire certain
176 //ui actions which helps triggering possible
177 $test = $this;
178 $this->customFieldSetLoadOnTheFlyCheck($customSets, $pageUrl,
179 function() use ($test) {
180 $test->select('membership_type_id_0', 'value=1');
181 }
182 );
c4e6d4e8 183 }
232624b1 184}