3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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';
28 class WebTest_Member_BatchUpdateViaProfileTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testMemberAdd() {
35 // Log in using webtestLogin() method
36 $this->webtestLogin();
38 // Create a membership type to use for this test (defaults for this helper function are rolling 1 year membership)
39 $memTypeParams = $this->webtestAddMembershipType();
41 $endDate = date('F jS, Y', strtotime("+1 year +1 month -1 day"));
43 // Add new individual using Quick Add block on the main page
44 $firstName1 = "John_" . substr(sha1(rand()), 0, 7);
45 $lastName = "Smith_" . substr(sha1(rand()), 0, 7);
46 $Name1 = $lastName . ', ' . $firstName1;
47 $this->webtestAddContact($firstName1, $lastName, "$firstName1.$lastName@example.com");
48 $this->waitForPageToLoad($this->getTimeoutMsec());
50 // Add membership for this individual
51 $this->_addMembership($memTypeParams);
52 // Is status message correct?
53 $this->waitForText('crm-notification-container', "membership for $firstName1 $lastName has been added");
55 // click through to the membership view screen
56 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
57 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
61 'Membership Type' => $memTypeParams['membership_type'],
63 'End date' => $endDate,
65 $this->webtestVerifyTabularData($verifyData);
67 // Add new individual using Quick Add block on the main page
68 $firstName2 = "John_" . substr(sha1(rand()), 0, 7);
69 $Name2 = $lastName . ', ' . $firstName2;
70 $this->webtestAddContact($firstName2, $lastName, "$firstName2.$lastName@example.com");
71 $this->waitForPageToLoad($this->getTimeoutMsec());
73 // Add membership for this individual
74 $this->_addMembership($memTypeParams);
75 // Is status message correct?
77 $this->waitForText('crm-notification-container', "membership for $firstName2 $lastName has been added.");
79 // click through to the membership view screen
80 $this->click("xpath=//div[@id='memberships']//table//tbody/tr[1]/td[9]/span/a[text()='View']");
81 $this->waitForElementPresent("_qf_MembershipView_cancel-bottom");
85 'Membership Type' => $memTypeParams['membership_type'],
87 'End date' => $endDate,
89 $this->webtestVerifyTabularData($verifyData);
91 $profileTitle = 'Profile_' . substr(sha1(rand()), 0, 4);
92 $customDataParams = $this->_addCustomData();
93 $this->_addProfile($profileTitle, $customDataParams);
96 $this->openCiviPage("member/search", "reset=1", '_qf_Search_refresh');
98 $this->type('sort_name', $lastName);
99 $this->click('_qf_Search_refresh');
100 $this->waitForElementPresent('_qf_Search_next_print');
102 // Batch Update Via Profile
103 $this->click("xpath=//div[@id='search-status']/table/tbody/tr[2]/td[2]/input");
104 //$this->click('CIVICRM_QFID_ts_all_10');
105 $this->select('task', "label=Batch Update Members Via Profile");
107 $this->waitForElementPresent('_qf_PickProfile_back-bottom');
109 $this->select('uf_group_id', "label={$profileTitle}");
110 $this->click('_qf_PickProfile_next-bottom');
112 $this->waitForElementPresent('_qf_Batch_back-bottom');
113 $this->type("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']/../td[3]/input", "This is test custom data text1");
114 $this->select("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name1}']/../td[4]/select", "label=Current");
116 $this->type("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']/../td[3]/input", "This is test custom data text2");
117 $this->select("xpath=//form[@id='Batch']/div[2]/table/tbody//tr/td[text()='{$Name2}']/../td[4]/select", "label=Grace");
119 $this->click('_qf_Batch_next-bottom');
120 $this->waitForElementPresent('_qf_Result_done');
121 $this->click('_qf_Result_done');
122 $this->waitForElementPresent('_qf_Search_next_print');
125 $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[3]/a[text()='{$Name1}']/../../td[11]/span/a[text()='View']");
126 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
130 'Membership Type' => $memTypeParams['membership_type'],
131 'Status' => 'Current',
132 'End date' => $endDate,
134 $this->webtestVerifyTabularData($verifyData);
136 $this->click('_qf_MembershipView_cancel-bottom');
137 $this->waitForElementPresent('_qf_Search_next_print');
140 $this->click("xpath=//div[@id='memberSearch']/table/tbody//tr/td[3]/a[text()='{$Name2}']/../../td[11]/span/a[text()='View']");
141 $this->waitForElementPresent('_qf_MembershipView_cancel-bottom');
145 'Membership Type' => $memTypeParams['membership_type'],
147 'End date' => $endDate,
149 $this->webtestVerifyTabularData($verifyData);
152 function _addMembership($memTypeParams) {
153 // click through to the membership view screen
154 $this->click("css=li#tab_member a");
155 $this->waitForElementPresent("link=Add Membership");
156 $this->click("link=Add Membership");
157 $this->waitForElementPresent("_qf_Membership_cancel-bottom");
159 // fill in Membership Organization and Type
160 $this->select("membership_type_id[0]", "label={$memTypeParams['member_of_contact']}");
161 // Wait for membership type select to reload
162 $this->waitForTextPresent($memTypeParams['membership_type']);
163 // Because it tends to cause problems, all uses of sleep() must be justified in comments
164 // Sleep should never be used for wait for anything to load from the server
165 // Justification for this instance: FIXME
167 $this->select("membership_type_id[1]", "label={$memTypeParams['membership_type']}");
169 $sourceText = "Membership ContactAddTest Webtest";
171 $this->type("source", $sourceText);
173 // Let Join Date stay default
175 // fill in Start Date
176 $this->webtestFillDate('start_date');
179 $this->click("_qf_Membership_upload");
180 $this->waitForPageToLoad($this->getTimeoutMsec());
183 $this->waitForTextPresent($sourceText);
186 function _addProfile($profileTitle, $customDataParams) {
188 $this->openCiviPage("admin/uf/group", "reset=1");
190 $this->click('link=Add Profile');
191 // Add membership custom data field to profile
192 $this->waitForElementPresent('_qf_Group_cancel-bottom');
193 $this->type('title', $profileTitle);
194 $this->click('_qf_Group_next-bottom');
196 $this->waitForElementPresent('_qf_Field_cancel-bottom');
197 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
199 $this->select('field_name[0]', "value=Membership");
200 $this->select('field_name[1]', "label={$customDataParams[0]} :: {$customDataParams[1]}");
201 $this->click('field_name[1]');
202 $this->click('label');
204 // Clicking save and new
205 $this->click('_qf_Field_next_new-bottom');
206 $this->waitForPageToLoad($this->getTimeoutMsec());
207 $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field '{$customDataParams[0]}' has been saved to '{$profileTitle}'.");
209 // Add membership status field to profile - CRM-8618
210 $this->select('field_name[0]', "value=Membership");
211 $this->select('field_name[1]', "label=Membership Status");
212 $this->click('field_name[1]');
213 $this->click('label');
215 $this->click('_qf_Field_next-bottom');
216 $this->waitForPageToLoad($this->getTimeoutMsec());
217 $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Membership Status' has been saved to '{$profileTitle}'.");
220 function _addCustomData() {
221 $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 4);
223 $this->openCiviPage('admin/custom/group', 'reset=1');
225 //add new custom data
226 $this->click("//a[@id='newCustomDataGroup']/span");
227 $this->waitForPageToLoad($this->getTimeoutMsec());
229 //fill custom group title
230 $this->click("title");
231 $this->type("title", $customGroupTitle);
233 //custom group extends
234 $this->click("extends[0]");
235 $this->select("extends[0]", "value=Membership");
236 $this->click("//option[@value='Membership']");
237 $this->click('_qf_Group_next-bottom');
238 $this->waitForElementPresent('_qf_Field_cancel-bottom');
240 //Is custom group created?
241 $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now.");
243 $textFieldLabel = 'Custom Field Text_' . substr(sha1(rand()), 0, 4);
244 $this->type('label', $textFieldLabel);
247 $this->type('help_pre', "this is field pre help");
249 //enter post help msg
250 $this->type('help_post', "this is field post help");
253 $this->click('is_searchable');
256 $this->click('_qf_Field_next');
257 $this->waitForPageToLoad($this->getTimeoutMsec());
259 //Is custom field created
260 $this->waitForText('crm-notification-container', "Your custom field '$textFieldLabel' has been saved.");
262 return array($textFieldLabel, $customGroupTitle);