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