Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
e7112fa7 | 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
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() { |
6a488035 | 39 | // Log in as admin first to verify permissions for CiviCase |
80f3b91d | 40 | $this->webtestLogin('admin'); |
6a488035 TO |
41 | |
42 | // Enable CiviCase module if necessary | |
b9715b8a | 43 | $this->enableComponents("CiviCase"); |
6a488035 TO |
44 | |
45 | // let's give full CiviCase permissions to demo user (registered user). | |
92915c55 TO |
46 | $permission = array( |
47 | 'edit-2-access-all-cases-and-activities', | |
48 | 'edit-2-access-my-cases-and-activities', | |
49 | 'edit-2-administer-civicase', | |
389bcebf | 50 | 'edit-2-delete-in-civicase', |
92915c55 | 51 | ); |
6a488035 TO |
52 | $this->changePermissions($permission); |
53 | ||
42daf119 CW |
54 | // Log in as normal user |
55 | $this->webtestLogin(); | |
56 | ||
d2771e94 | 57 | $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); |
6a488035 TO |
58 | |
59 | // Adding contact with randomized first name (so we can then select that contact when creating case) | |
60 | // We're using pop-up New Contact dialog | |
80f3b91d | 61 | $contact = $this->createDialogContact("client_id"); |
6a488035 TO |
62 | |
63 | // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. | |
64 | $caseTypeLabel = "Adult Day Care Referral"; | |
65 | $subject = "Safe daytime setting - senior female"; | |
66 | $this->select('medium_id', 'value=1'); | |
67 | $this->type('activity_location', 'Main offices'); | |
68 | $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented."; | |
69 | $this->fillRichTextField("activity_details", $details, 'CKEditor'); | |
70 | $this->type('activity_subject', $subject); | |
71 | ||
72 | $this->select('case_type_id', "label={$caseTypeLabel}"); | |
73 | ||
74 | // Choose Case Start Date. | |
75 | // Using helper webtestFillDate function. | |
76 | $this->webtestFillDate('start_date', 'now'); | |
77 | $today = date('F jS, Y', strtotime('now')); | |
76e86fd8 | 78 | |
6a488035 | 79 | $this->type('duration', "20"); |
44c45561 | 80 | $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom', FALSE); |
6a488035 TO |
81 | |
82 | // Is status message correct? | |
80f3b91d | 83 | $this->checkCRMAlert("Case opened successfully."); |
6a488035 TO |
84 | $customGroupTitle = 'Custom_' . substr(sha1(rand()), 0, 7); |
85 | ||
80f3b91d | 86 | $this->_testAddNewActivity($contact['first_name'], $subject, $customGroupTitle, $contact['sort_name']); |
6a488035 TO |
87 | } |
88 | ||
00be9182 | 89 | public function testLinkCases() { |
a40669b6 CW |
90 | // Log in as admin first to verify permissions for CiviCase |
91 | $this->webtestLogin('admin'); | |
3f4fcdb9 RK |
92 | |
93 | // Enable CiviCase module if necessary | |
ca70bd72 | 94 | $this->enableComponents("CiviCase"); |
3f4fcdb9 | 95 | |
a40669b6 | 96 | // let's give full CiviCase permissions to demo user (registered user). |
92915c55 TO |
97 | $permission = array( |
98 | 'edit-2-access-all-cases-and-activities', | |
99 | 'edit-2-access-my-cases-and-activities', | |
100 | 'edit-2-administer-civicase', | |
389bcebf | 101 | 'edit-2-delete-in-civicase', |
92915c55 | 102 | ); |
a40669b6 CW |
103 | $this->changePermissions($permission); |
104 | ||
105 | // Log in as normal user | |
106 | $this->webtestLogin(); | |
107 | ||
8e05e179 JP |
108 | //Add Case 1 |
109 | $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); | |
110 | ||
111 | // Adding contact with randomized first name (so we can then select that contact when creating case) | |
112 | // We're using pop-up New Contact dialog | |
80f3b91d | 113 | $contact1 = $this->createDialogContact('client_id'); |
8e05e179 JP |
114 | |
115 | // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. | |
116 | $caseTypeLabel = "Adult Day Care Referral"; | |
117 | $subject = "Safe daytime setting - senior female"; | |
118 | $this->select('medium_id', 'value=1'); | |
119 | $this->type('activity_location', 'Main offices'); | |
120 | $details = "65 year old female needs safe location during the day for herself and her dog. She is in good health but somewhat disoriented."; | |
121 | $this->fillRichTextField("activity_details", $details, 'CKEditor'); | |
122 | $this->type('activity_subject', $subject); | |
123 | ||
124 | $this->select('case_type_id', "label={$caseTypeLabel}"); | |
125 | ||
126 | // Choose Case Start Date. | |
127 | // Using helper webtestFillDate function. | |
128 | $this->webtestFillDate('start_date', 'now'); | |
129 | $today = date('F jS, Y', strtotime('now')); | |
130 | ||
131 | $this->type('duration', "20"); | |
80f3b91d | 132 | $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom'); |
8e05e179 JP |
133 | |
134 | // Is status message correct? | |
80f3b91d | 135 | $this->checkCRMAlert("Case opened successfully."); |
8e05e179 JP |
136 | |
137 | //Add Case 2 | |
138 | $this->openCiviPage('case/add', 'reset=1&action=add&atype=13&context=standalone', '_qf_Case_upload-bottom'); | |
139 | ||
140 | // Adding contact with randomized first name (so we can then select that contact when creating case) | |
141 | // We're using pop-up New Contact dialog | |
80f3b91d | 142 | $contact2 = $this->createDialogContact('client_id'); |
8e05e179 JP |
143 | |
144 | // Fill in other form values. We'll use a case type which is included in CiviCase sample data / xml files. | |
145 | $caseTypeLabel2 = "Adult Day Care Referral"; | |
146 | $subject2 = "Subject For Case 2"; | |
147 | $this->select('medium_id', 'value=1'); | |
148 | $this->type('activity_location', 'Main offices'); | |
149 | $details2 = "Details For Case 2"; | |
150 | $this->fillRichTextField("activity_details", $details2, 'CKEditor'); | |
151 | $this->type('activity_subject', $subject2); | |
152 | ||
153 | $this->select('case_type_id', "label={$caseTypeLabel2}"); | |
154 | ||
155 | // Choose Case Start Date. | |
156 | // Using helper webtestFillDate function. | |
157 | $this->webtestFillDate('start_date', 'now'); | |
158 | $today = date('F jS, Y', strtotime('now')); | |
159 | ||
160 | $this->type('duration', "20"); | |
80f3b91d | 161 | $this->clickLink('_qf_Case_upload-bottom', '_qf_CaseView_cancel-bottom'); |
8e05e179 JP |
162 | |
163 | // Is status message correct? | |
80f3b91d | 164 | $this->checkCRMAlert("Case opened successfully."); |
8e05e179 | 165 | |
80f3b91d CW |
166 | // We should now be on the "manage case" screen for case 2 |
167 | //Add Link Case Activity to case 1 | |
8e05e179 JP |
168 | $this->select('add_activity_type_id', 'Link Cases'); |
169 | $this->waitForElementPresent("_qf_Activity_cancel-bottom"); | |
80f3b91d | 170 | $this->select2('link_to_case_id', $contact1['sort_name']); |
8e05e179 JP |
171 | $activitydetails = 'Details of Link Case Activity'; |
172 | $this->fillRichTextField("details", $activitydetails, 'CKEditor'); | |
80f3b91d CW |
173 | $this->click('css=#activity-details .crm-accordion-header'); |
174 | $this->waitForVisible('subject'); | |
8e05e179 JP |
175 | $activitySubject = 'Link Case Activity between case 1 and case 2'; |
176 | $activitylocation = 'Main Office Building'; | |
80f3b91d | 177 | $this->select2('source_contact_id', $contact2['sort_name']); |
8e05e179 JP |
178 | $this->type('subject', $activitySubject); |
179 | $this->type('location', $activitylocation); | |
80f3b91d | 180 | $this->clickAjaxLink('_qf_Activity_upload-bottom'); |
8e05e179 JP |
181 | $id = $this->urlArg('id'); |
182 | $this->waitForText("case_id_$id", $activitySubject); | |
a7011f01 | 183 | $this->click("xpath=//table[@id='case_id_{$id}']/tbody//tr/td[2]/div[text()='{$activitySubject}']/../../td[8]/a[text()='View']"); |
8e05e179 JP |
184 | |
185 | $LinkCaseActivityData = array( | |
80f3b91d | 186 | "Client" => $contact2['first_name'], |
8e05e179 JP |
187 | "Activity Type" => "Link Cases", |
188 | "Subject" => $activitySubject, | |
80f3b91d | 189 | "Reported By" => $contact2['display_name'], |
8e05e179 JP |
190 | "Medium" => "Phone", |
191 | "Location" => $activitylocation, | |
192 | "Date and Time" => $today, | |
193 | "Details" => $activitydetails, | |
194 | "Status" => "Scheduled", | |
195 | "Priority" => "Normal", | |
196 | ); | |
197 | $this->webtestVerifyTabularData($LinkCaseActivityData); | |
198 | } | |
92915c55 | 199 | |
4cbe18b8 | 200 | /** |
100fef9d | 201 | * @param string $firstName |
4cbe18b8 EM |
202 | * @param $caseSubject |
203 | * @param $customGroupTitle | |
204 | * @param $contactName | |
205 | */ | |
00be9182 | 206 | public function _testAddNewActivity($firstName, $caseSubject, $customGroupTitle, $contactName) { |
6a488035 TO |
207 | $customDataParams = $this->_addCustomData($customGroupTitle); |
208 | //$customDataParams = array( 'optionLabel_47d58', 'custom_8_-1' ); | |
209 | ||
210 | // Adding Adding contact with randomized first name for test testContactContextActivityAdd | |
211 | // We're using Quick Add block on the main page for this. | |
212 | $firstName1 = substr(sha1(rand()), 0, 7); | |
213 | $this->webtestAddContact($firstName1, "Summerson", $firstName1 . "@summerson.name"); | |
214 | $firstName2 = substr(sha1(rand()), 0, 7); | |
215 | $this->webtestAddContact($firstName2, "Anderson", $firstName2 . "@anderson.name"); | |
216 | ||
6a488035 TO |
217 | $this->click("css=li#tab_activity a"); |
218 | ||
219 | // waiting for the activity dropdown to show up | |
220 | $this->waitForElementPresent("other_activity"); | |
221 | ||
222 | // Select the activity type from the activity dropdown | |
223 | $this->select("other_activity", "label=Meeting"); | |
224 | ||
225 | // waitForPageToLoad is not always reliable. Below, we're waiting for the submit | |
226 | // button at the end of this page to show up, to make sure it's fully loaded. | |
227 | $this->waitForElementPresent("_qf_Activity_upload-bottom"); | |
228 | ||
6a488035 | 229 | // ...and verifying if the page contains properly formatted display name for chosen contact. |
44c45561 | 230 | $this->waitForText("xpath=//div[@id='s2id_target_contact_id']", 'Anderson, ' . $firstName2, "Contact not found in line " . __LINE__); |
6a488035 TO |
231 | |
232 | // Now we're filling the "Assigned To" field. | |
233 | // Typing contact's name into the field (using typeKeys(), not type()!)... | |
44c45561 | 234 | $this->click("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input"); |
235 | $this->keyDown("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", " "); | |
236 | $this->type("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1); | |
237 | $this->typeKeys("xpath=//div[@id='s2id_assignee_contact_id']/ul/li/input", $firstName1); | |
6a488035 TO |
238 | |
239 | // ...waiting for drop down with results to show up... | |
44c45561 | 240 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
241 | |
242 | //..need to use mouseDownAt on first result (which is a li element), click does not work | |
44c45561 | 243 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
244 | |
245 | // ...again, waiting for the box with contact name to show up... | |
6c6e6187 | 246 | $this->waitForText("xpath=//div[@id='s2id_assignee_contact_id']", "$firstName1"); |
6a488035 TO |
247 | |
248 | // ...and verifying if the page contains properly formatted display name for chosen contact. | |
44c45561 | 249 | $this->assertElementContainsText("xpath=//div[@id='s2id_assignee_contact_id']", "Summerson, $firstName1", 'Contact not found in line ' . __LINE__); |
6a488035 TO |
250 | |
251 | // Putting the contents into subject field - assigning the text to variable, it'll come in handy later | |
252 | $subject = "This is subject of test activity being added through activity tab of contact summary screen."; | |
253 | // For simple input fields we can use field id as selector | |
254 | $this->type("subject", $subject); | |
255 | $this->type("location", "Some location needs to be put in this field."); | |
256 | ||
257 | // Choosing the Date. | |
258 | // Please note that we don't want to put in fixed date, since | |
259 | // we want this test to work in the future and not fail because | |
260 | // of date being set in the past. Therefore, using helper webtestFillDateTime function. | |
261 | $this->webtestFillDateTime('activity_date_time', '+1 month 11:10PM'); | |
262 | ||
263 | // Setting duration. | |
264 | $this->type("duration", "30"); | |
265 | ||
266 | // Putting in details. | |
267 | $this->type("details", "Really brief details information."); | |
268 | ||
269 | // Making sure that status is set to Scheduled (using value, not label). | |
270 | $this->select("status_id", "value=1"); | |
271 | ||
272 | // Setting priority. | |
273 | $this->select("priority_id", "value=1"); | |
274 | ||
275 | $textField = 'This is test custom data'; | |
44c45561 | 276 | $this->click("xpath=//div[@id='customData']//div[@class='custom-group custom-group-$customGroupTitle crm-accordion-wrapper collapsed']"); |
277 | $this->waitForElementPresent("xpath=//div[@class='crm-accordion-body']//table/tbody/tr[2]/td[2]/table/tbody/tr/td[1]/input"); | |
278 | $this->click("xpath=//div[@class='crm-accordion-body']//table/tbody/tr[2]/td[2]/table/tbody/tr/td[1]/input"); | |
6a488035 TO |
279 | $this->type($customDataParams[1], $textField); |
280 | ||
281 | // Scheduling follow-up. | |
282 | $this->click("css=.crm-activity-form-block-schedule_followup div.crm-accordion-header"); | |
283 | $this->select("followup_activity_type_id", "value=1"); | |
284 | $this->webtestFillDateTime('followup_date', '+2 months 10:00AM'); | |
285 | $this->type("followup_activity_subject", "This is subject of schedule follow-up activity"); | |
286 | ||
287 | // Clicking save. | |
288 | $this->click("_qf_Activity_upload-bottom"); | |
6a488035 TO |
289 | |
290 | // Is status message correct? | |
6c5f7368 | 291 | $this->waitForText('crm-notification-container', $subject); |
6a488035 TO |
292 | |
293 | // click through to the Activity view screen | |
ca70bd72 RK |
294 | $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']"); |
295 | $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']"); | |
296 | $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"); | |
297 | $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 |
298 | |
299 | // file activity on case | |
ca70bd72 | 300 | $this->waitForElementPresent('file_on_case_unclosed_case_id'); |
44c45561 | 301 | $this->select2('file_on_case_unclosed_case_id', $firstName); |
302 | $this->assertElementContainsText("xpath=//div[@id='s2id_file_on_case_unclosed_case_id']", "$firstName", 'Contact not found in line ' . __LINE__); | |
ca70bd72 | 303 | $this->type('file_on_case_activity_subject', $subject); |
44c45561 | 304 | $this->click("xpath=//div[@class='ui-dialog-buttonset']/button/span[text()='Save']"); |
ca70bd72 | 305 | $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 |
306 | |
307 | // verify if custom data is present | |
d2771e94 | 308 | $this->openCiviPage('case', 'reset=1'); |
6a488035 TO |
309 | $this->click("xpath=//table[@class='caseSelector']/tbody//tr/td[2]/a[text()='{$contactName}']/../../td[9]/span/a[text()='Manage']"); |
310 | ||
311 | $this->waitForElementPresent('_qf_CaseView_cancel-bottom'); | |
44c45561 | 312 | $id = $this->urlArg('id'); |
92fcb95f | 313 | $this->waitForElementPresent("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody/tr[1]/td[2]"); |
6a488035 | 314 | |
fb93fc39 | 315 | $this->click("xpath=//div[@id='activities']//table[@id='case_id_" . $id . "']/tbody/tr[1]/td[2]/div[text()='{$subject}']/../../td[8]/a[1]"); |
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 | } |