Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
2fe49090 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
8c9251b3 | 6 | | Copyright CiviCRM LLC (c) 2004-2018 | |
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Case_ActivityToCaseTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Case_ActivityToCaseTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testAddActivityToCase() { |
f75b8467 | 39 | $this->markTestSkipped('Skipping for now as it works fine locally.'); |
6a488035 | 40 | // Log in as admin first to verify permissions for CiviCase |
80f3b91d | 41 | $this->webtestLogin('admin'); |
6a488035 TO |
42 | |
43 | // Enable CiviCase module if necessary | |
b9715b8a | 44 | $this->enableComponents("CiviCase"); |
6a488035 TO |
45 | |
46 | // let's give full CiviCase permissions to demo user (registered user). | |
92915c55 TO |
47 | $permission = array( |
48 | 'edit-2-access-all-cases-and-activities', | |
49 | 'edit-2-access-my-cases-and-activities', | |
50 | 'edit-2-administer-civicase', | |
389bcebf | 51 | 'edit-2-delete-in-civicase', |
92915c55 | 52 | ); |
6a488035 TO |
53 | $this->changePermissions($permission); |
54 | ||
42daf119 CW |
55 | // Log in as normal user |
56 | $this->webtestLogin(); | |
57 | ||
d2771e94 | 58 | $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); |
6a488035 TO |
59 | |
60 | // Adding contact with randomized first name (so we can then select that contact when creating case) | |
61 | // We're using pop-up New Contact dialog | |
80f3b91d | 62 | $contact = $this->createDialogContact("client_id"); |
6a488035 TO |
63 | |
64 | // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. | |
65 | $caseTypeLabel = "Adult Day Care Referral"; | |
66 | $subject = "Safe daytime setting - senior female"; | |
67 | $this->select('medium_id', 'value=1'); | |
68 | $this->type('activity_location', 'Main offices'); | |
69 | $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented."; | |
70 | $this->fillRichTextField("activity_details", $details, 'CKEditor'); | |
71 | $this->type('activity_subject', $subject); | |
72 | ||
73 | $this->select('case_type_id', "label={$caseTypeLabel}"); | |
74 | ||
75 | // Choose Case Start Date. | |
76 | // Using helper webtestFillDate function. | |
77 | $this->webtestFillDate('start_date', 'now'); | |
78 | $today = date('F jS, Y', strtotime('now')); | |
76e86fd8 | 79 | |
6a488035 | 80 | $this->type('duration', "20"); |
44c45561 | 81 | $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom', FALSE); |
6a488035 TO |
82 | |
83 | // Is status message correct? | |
80f3b91d | 84 | $this->checkCRMAlert("Case opened successfully."); |
6a488035 TO |
85 | $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 7); |
86 | ||
80f3b91d | 87 | $this->_testAddNewActivity($contact['first_name'], $subject, $customGroupTitle, $contact['sort_name']); |
6a488035 TO |
88 | } |
89 | ||
00be9182 | 90 | public function testLinkCases() { |
a40669b6 CW |
91 | // Log in as admin first to verify permissions for CiviCase |
92 | $this->webtestLogin('admin'); | |
3f4fcdb9 RK |
93 | |
94 | // Enable CiviCase module if necessary | |
ca70bd72 | 95 | $this->enableComponents("CiviCase"); |
3f4fcdb9 | 96 | |
a40669b6 | 97 | // let's give full CiviCase permissions to demo user (registered user). |
92915c55 TO |
98 | $permission = array( |
99 | 'edit-2-access-all-cases-and-activities', | |
100 | 'edit-2-access-my-cases-and-activities', | |
101 | 'edit-2-administer-civicase', | |
389bcebf | 102 | 'edit-2-delete-in-civicase', |
92915c55 | 103 | ); |
a40669b6 CW |
104 | $this->changePermissions($permission); |
105 | ||
106 | // Log in as normal user | |
107 | $this->webtestLogin(); | |
108 | ||
8e05e179 JP |
109 | //Add Case 1 |
110 | $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); | |
111 | ||
112 | // Adding contact with randomized first name (so we can then select that contact when creating case) | |
113 | // We're using pop-up New Contact dialog | |
80f3b91d | 114 | $contact1 = $this->createDialogContact('client_id'); |
8e05e179 JP |
115 | |
116 | // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. | |
117 | $caseTypeLabel = "Adult Day Care Referral"; | |
118 | $subject = "Safe daytime setting - senior female"; | |
119 | $this->select('medium_id', 'value=1'); | |
120 | $this->type('activity_location', 'Main offices'); | |
121 | $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented."; | |
122 | $this->fillRichTextField("activity_details", $details, 'CKEditor'); | |
123 | $this->type('activity_subject', $subject); | |
124 | ||
125 | $this->select('case_type_id', "label={$caseTypeLabel}"); | |
126 | ||
127 | // Choose Case Start Date. | |
128 | // Using helper webtestFillDate function. | |
129 | $this->webtestFillDate('start_date', 'now'); | |
130 | $today = date('F jS, Y', strtotime('now')); | |
131 | ||
132 | $this->type('duration', "20"); | |
80f3b91d | 133 | $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom'); |
8e05e179 JP |
134 | |
135 | // Is status message correct? | |
80f3b91d | 136 | $this->checkCRMAlert("Case opened successfully."); |
8e05e179 JP |
137 | |
138 | //Add Case 2 | |
139 | $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); | |
140 | ||
141 | // Adding contact with randomized first name (so we can then select that contact when creating case) | |
142 | // We're using pop-up New Contact dialog | |
80f3b91d | 143 | $contact2 = $this->createDialogContact('client_id'); |
8e05e179 JP |
144 | |
145 | // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. | |
146 | $caseTypeLabel2 = "Adult Day Care Referral"; | |
147 | $subject2 = "Subject For Case 2"; | |
148 | $this->select('medium_id', 'value=1'); | |
149 | $this->type('activity_location', 'Main offices'); | |
150 | $details2 = "Details For Case 2"; | |
151 | $this->fillRichTextField("activity_details", $details2, 'CKEditor'); | |
152 | $this->type('activity_subject', $subject2); | |
153 | ||
154 | $this->select('case_type_id', "label={$caseTypeLabel2}"); | |
155 | ||
156 | // Choose Case Start Date. | |
157 | // Using helper webtestFillDate function. | |
158 | $this->webtestFillDate('start_date', 'now'); | |
159 | $today = date('F jS, Y', strtotime('now')); | |
160 | ||
161 | $this->type('duration', "20"); | |
80f3b91d | 162 | $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom'); |
8e05e179 JP |
163 | |
164 | // Is status message correct? | |
80f3b91d | 165 | $this->checkCRMAlert("Case opened successfully."); |
8e05e179 | 166 | |
80f3b91d CW |
167 | // We should now be on the "manage case" screen for case 2 |
168 | //Add Link Case Activity to case 1 | |
8e05e179 JP |
169 | $this->select('add_activity_type_id', 'Link Cases'); |
170 | $this->waitForElementPresent("_qf_Activity_cancel-bottom"); | |
80f3b91d | 171 | $this->select2('link_to_case_id', $contact1['sort_name']); |
8e05e179 JP |
172 | $activitydetails = 'Details of Link Case Activity'; |
173 | $this->fillRichTextField("details", $activitydetails, 'CKEditor'); | |
80f3b91d CW |
174 | $this->click('css=#activity-details .crm-accordion-header'); |
175 | $this->waitForVisible('subject'); | |
8e05e179 JP |
176 | $activitySubject = 'Link Case Activity between case 1 and case 2'; |
177 | $activitylocation = 'Main Office Building'; | |
80f3b91d | 178 | $this->select2('source_contact_id', $contact2['sort_name']); |
8e05e179 JP |
179 | $this->type('subject', $activitySubject); |
180 | $this->type('location', $activitylocation); | |
80f3b91d | 181 | $this->clickAjaxLink('_qf_Activity_upload-bottom'); |
8e05e179 JP |
182 | $id = $this->urlArg('id'); |
183 | $this->waitForText("case_id_$id", $activitySubject); | |
a7011f01 | 184 | $this->click("xpath=//table[@id='case_id_{$id}']/tbody//tr/td[2]/div[text()='{$activitySubject}']/../../td[8]/a[text()='View']"); |
8e05e179 JP |
185 | |
186 | $LinkCaseActivityData = array( | |
80f3b91d | 187 | "Client" => $contact2['first_name'], |
8e05e179 JP |
188 | "Activity Type" => "Link Cases", |
189 | "Subject" => $activitySubject, | |
80f3b91d | 190 | "Reported By" => $contact2['display_name'], |
8e05e179 JP |
191 | "Medium" => "Phone", |
192 | "Location" => $activitylocation, | |
193 | "Date and Time" => $today, | |
194 | "Details" => $activitydetails, | |
195 | "Status" => "Scheduled", | |
196 | "Priority" => "Normal", | |
197 | ); | |
198 | $this->webtestVerifyTabularData($LinkCaseActivityData); | |
199 | } | |
92915c55 | 200 | |
4cbe18b8 | 201 | /** |
100fef9d | 202 | * @param string $firstName |
4cbe18b8 EM |
203 | * @param $caseSubject |
204 | * @param $customGroupTitle | |
205 | * @param $contactName | |
206 | */ | |
00be9182 | 207 | public function _testAddNewActivity($firstName, $caseSubject, $customGroupTitle, $contactName) { |
6a488035 TO |
208 | $customDataParams = $this->_addCustomData($customGroupTitle); |
209 | //$customDataParams = array( 'optionLabel_47d58', 'custom_8_-1' ); | |
210 | ||
211 | // Adding Adding contact with randomized first name for test testContactContextActivityAdd | |
212 | // We're using Quick Add block on the main page for this. | |
213 | $firstName1 = substr(sha1(rand()), 0, 7); | |
214 | $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name"); | |
215 | $firstName2 = substr(sha1(rand()), 0, 7); | |
216 | $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name"); | |
217 | ||
6a488035 TO |
218 | $this->click("css=li#tab_activity a"); |
219 | ||
220 | // waiting for the activity dropdown to show up | |
221 | $this->waitForElementPresent("other_activity"); | |
222 | ||
223 | // Select the activity type from the activity dropdown | |
224 | $this->select("other_activity", "label=Meeting"); | |
225 | ||
226 | // waitForPageToLoad is not always reliable. Below, we're waiting for the submit | |
227 | // button at the end of this page to show up, to make sure it's fully loaded. | |
228 | $this->waitForElementPresent("_qf_Activity_upload-bottom"); | |
229 | ||
6a488035 | 230 | // ...and verifying if the page contains properly formatted display name for chosen contact. |
44c45561 | 231 | $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", 'Anderson, ' . $firstName2, "Contact not found in line " . __LINE__); |
6a488035 TO |
232 | |
233 | // Now we're filling the "Assigned To" field. | |
234 | // Typing contact's name into the field (using typeKeys(), not type()!)... | |
44c45561 | 235 | $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input"); |
236 | $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " "); | |
237 | $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1); | |
238 | $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1); | |
6a488035 TO |
239 | |
240 | // ...waiting for drop down with results to show up... | |
44c45561 | 241 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
242 | |
243 | //..need to use mouseDownAt on first result (which is a li element), click does not work | |
44c45561 | 244 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
245 | |
246 | // ...again, waiting for the box with contact name to show up... | |
6c6e6187 | 247 | $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$firstName1"); |
6a488035 TO |
248 | |
249 | // ...and verifying if the page contains properly formatted display name for chosen contact. | |
44c45561 | 250 | $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Summerson, $firstName1", 'Contact not found in line ' . __LINE__); |
6a488035 TO |
251 | |
252 | // Putting the contents into subject field - assigning the text to variable, it'll come in handy later | |
253 | $subject = "This is subject of test activity being added through activity tab of contact summary screen."; | |
254 | // For simple input fields we can use field id as selector | |
255 | $this->type("subject", $subject); | |
256 | $this->type("location", "Some location needs to be put in this field."); | |
257 | ||
258 | // Choosing the Date. | |
259 | // Please note that we don't want to put in fixed date, since | |
260 | // we want this test to work in the future and not fail because | |
261 | // of date being set in the past. Therefore, using helper webtestFillDateTime function. | |
262 | $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM'); | |
263 | ||
264 | // Setting duration. | |
265 | $this->type("duration", "30"); | |
266 | ||
267 | // Putting in details. | |
268 | $this->type("details", "Really brief details information."); | |
269 | ||
270 | // Making sure that status is set to Scheduled (using value, not label). | |
271 | $this->select("status_id", "value=1"); | |
272 | ||
273 | // Setting priority. | |
274 | $this->select("priority_id", "value=1"); | |
275 | ||
276 | $textField = 'This is test custom data'; | |
44c45561 | 277 | $this->click("xpath=//div[@id='customData']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']"); |
278 | $this->waitForElementPresent("xpath=//div[@class='crm-accordion-body']//table/tbody/tr[2]/td[2]/table/tbody/tr/td[1]/input"); | |
279 | $this->click("xpath=//div[@class='crm-accordion-body']//table/tbody/tr[2]/td[2]/table/tbody/tr/td[1]/input"); | |
6a488035 TO |
280 | $this->type($customDataParams[1], $textField); |
281 | ||
282 | // Scheduling follow-up. | |
283 | $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header"); | |
284 | $this->select("followup_activity_type_id", "value=1"); | |
285 | $this->webtestFillDateTime('followup_date', '+2 months 10:00AM'); | |
286 | $this->type("followup_activity_subject", "This is subject of schedule follow-up activity"); | |
287 | ||
288 | // Clicking save. | |
289 | $this->click("_qf_Activity_upload-bottom"); | |
6a488035 TO |
290 | |
291 | // Is status message correct? | |
6c5f7368 | 292 | $this->waitForText('crm-notification-container', $subject); |
6a488035 TO |
293 | |
294 | // click through to the Activity view screen | |
ca70bd72 RK |
295 | $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span/a[1][text()='View']"); |
296 | $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span/a[1][text()='View']"); | |
297 | $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span[2][text()='more']/ul[1]/li[1]/a"); | |
298 | $this->click("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span[2][text()='more']/ul[1]/li[1]/a"); | |
6a488035 TO |
299 | |
300 | // file activity on case | |
ca70bd72 | 301 | $this->waitForElementPresent('file_on_case_unclosed_case_id'); |
44c45561 | 302 | $this->select2('file_on_case_unclosed_case_id', $firstName); |
303 | $this->assertElementContainsText("xpath=//div[@id='s2id_file_on_case_unclosed_case_id']", "$firstName", 'Contact not found in line ' . __LINE__); | |
ca70bd72 | 304 | $this->type('file_on_case_activity_subject', $subject); |
35f01dcb | 305 | $this->click("xpath=//div[@class='ui-dialog-buttonset']//button//span[text()='Save']"); |
ca70bd72 | 306 | $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']/table/tbody//tr/td[5]/a[text()='Summerson, $firstName1']/../../td[8]/span/a[1][text()='View']"); |
6a488035 TO |
307 | |
308 | // verify if custom data is present | |
d2771e94 | 309 | $this->openCiviPage('case', 'reset=1'); |
6a488035 TO |
310 | $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[9]/span/a[text()='Manage']"); |
311 | ||
312 | $this->waitForElementPresent('_qf_CaseView_cancel-bottom'); | |
44c45561 | 313 | $id = $this->urlArg('id'); |
92fcb95f | 314 | $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody/tr[1]/td[2]"); |
35f01dcb | 315 | $this->click("xpath=//table[@id='case_id_" . $id . "']/tbody/tr[1]/td[2]/div[text()='{$subject}']/../../td[8]/a[text()='View']"); |
6a488035 | 316 | |
44c45561 | 317 | $this->waitForElementPresent('ActivityView'); |
6a488035 | 318 | $this->waitForElementPresent("css=table#crm-activity-view-table tr.crm-case-activityview-form-block-groupTitle"); |
d2771e94 | 319 | $this->assertElementContainsText('crm-activity-view-table', "$textField"); |
fb93fc39 | 320 | $this->click("xpath=//span[@class='ui-button-icon-primary ui-icon fa-times']"); |
92fcb95f | 321 | $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody/tr[1]/td[2]"); |
6a488035 | 322 | |
fb93fc39 | 323 | $this->click("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[7]/div[text()='Scheduled']"); |
6a488035 | 324 | |
fb93fc39 | 325 | $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[7]/div/form/select"); |
6a488035 TO |
326 | |
327 | // change activity status | |
fb93fc39 WA |
328 | $this->select("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[7]/div/form/select", 'value=2'); |
329 | $this->click("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[7]/div/form/button[@type='submit']"); | |
d2771e94 | 330 | $this->openCiviPage('case', 'reset=1'); |
6a488035 TO |
331 | $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[9]/span/a[text()='Manage']"); |
332 | $this->waitForElementPresent('_qf_CaseView_cancel-bottom'); | |
44c45561 | 333 | $id2 = $this->urlArg('id'); |
92fcb95f | 334 | $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_" . $id2 . "']/tbody/tr[1]/td[2]"); |
fb93fc39 | 335 | $this->click("xpath=//div[@id='activities']//table[@id='case_id_" . $id2 . "']/tbody//tr/td[2]/div[text()='{$subject}']/../../td[8]/a[1]"); |
44c45561 | 336 | $this->waitForElementPresent('ActivityView'); |
6a488035 TO |
337 | $this->waitForElementPresent("css=table#crm-activity-view-table tr.crm-case-activityview-form-block-groupTitle"); |
338 | } | |
339 | ||
4cbe18b8 EM |
340 | /** |
341 | * @param $customGroupTitle | |
342 | * | |
343 | * @return array | |
344 | */ | |
00be9182 | 345 | public function _addCustomData($customGroupTitle) { |
42daf119 | 346 | |
d2771e94 | 347 | $this->openCiviPage('admin/custom/group', 'reset=1'); |
6a488035 TO |
348 | |
349 | //add new custom data | |
57e9cdaf | 350 | $this->clickLink("//a[@id='newCustomDataGroup']/span"); |
6a488035 TO |
351 | |
352 | //fill custom group title | |
353 | $this->click("title"); | |
354 | $this->type("title", $customGroupTitle); | |
355 | ||
356 | //custom group extends | |
357 | $this->click("extends[0]"); | |
358 | $this->select("extends[0]", "value=Activity"); | |
359 | $this->click("//option[@value='Activity']"); | |
7df6dc24 | 360 | $this->clickLink('_qf_Group_next-bottom'); |
6a488035 TO |
361 | |
362 | //Is custom group created? | |
6c5f7368 | 363 | $this->waitForText('crm-notification-container', "Your custom field set '{$customGroupTitle}' has been added. You can add custom fields now."); |
6a488035 TO |
364 | |
365 | // create a custom field - Integer Radio | |
57e9cdaf | 366 | $this->clickLinkSuppressPopup('newCustomField', "data_type[0]"); |
6a488035 TO |
367 | $this->click("data_type[0]"); |
368 | $this->select("data_type[0]", "value=1"); | |
369 | $this->click("//option[@value='1']"); | |
370 | $this->click("data_type[1]"); | |
371 | $this->select("data_type[1]", "value=Radio"); | |
372 | $this->click("//option[@value='Radio']"); | |
373 | ||
374 | $radioFieldLabel = 'Custom Field Radio_' . substr(sha1(rand()), 0, 4); | |
375 | $this->type("label", $radioFieldLabel); | |
376 | $radioOptionLabel1 = 'optionLabel_' . substr(sha1(rand()), 0, 5); | |
377 | $this->type("option_label_1", $radioOptionLabel1); | |
378 | $this->type("option_value_1", "1"); | |
379 | $radioOptionLabel2 = 'optionLabel_' . substr(sha1(rand()), 0, 5); | |
380 | $this->type("option_label_2", $radioOptionLabel2); | |
381 | $this->type("option_value_2", "2"); | |
382 | ||
383 | //select options per line | |
384 | $this->type("options_per_line", "3"); | |
385 | ||
386 | //enter pre help msg | |
387 | $this->type("help_pre", "this is field pre help"); | |
388 | ||
389 | //enter post help msg | |
390 | $this->type("help_post", "this is field post help"); | |
391 | ||
392 | //Is searchable? | |
393 | $this->click("is_searchable"); | |
394 | ||
395 | //clicking save | |
57e9cdaf | 396 | $this->clickLink("_qf_Field_next_new-bottom", "_qf_Field_next_new-bottom"); |
6a488035 TO |
397 | |
398 | //Is custom field created | |
44c45561 | 399 | $this->waitForText('crm-notification-container', "Custom field '$radioFieldLabel' has been saved."); |
6a488035 TO |
400 | |
401 | // create another custom field - text field | |
6a488035 TO |
402 | $textFieldLabel = 'Custom Field Text_' . substr(sha1(rand()), 0, 4); |
403 | $this->type('label', $textFieldLabel); | |
404 | ||
405 | //enter pre help msg | |
406 | $this->type('help_pre', "this is field pre help"); | |
407 | ||
408 | //enter post help msg | |
409 | $this->type('help_post', "this is field post help"); | |
410 | ||
411 | //Is searchable? | |
412 | $this->click('is_searchable'); | |
413 | ||
414 | //clicking save | |
57e9cdaf | 415 | $this->clickLink("_qf_Field_done-bottom", "//a[@id='newCustomField']/span"); |
6a488035 TO |
416 | |
417 | //Is custom field created | |
44c45561 | 418 | $this->waitForText('crm-notification-container', "Custom field '$textFieldLabel' has been saved."); |
4a058f26 | 419 | $textFieldId = explode('&id=', $this->getAttribute("xpath=//table[@id='options']/tbody//tr/td[1]/div[text()='$textFieldLabel']/../../td[8]/span/a[1][text()='Edit Field']/@href")); |
6a488035 TO |
420 | $textFieldId = $textFieldId[1]; |
421 | ||
422 | return array($radioOptionLabel1, "custom_{$textFieldId}_-1"); | |
423 | } | |
96025800 | 424 | |
6a488035 | 425 | } |