Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
81621fee | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
fa938177 | 6 | | Copyright CiviCRM LLC (c) 2004-2016 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Admin_CustomAddTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Admin_CustomAddTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testCustomAdd() { |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | ||
bb21371e | 41 | $this->openCiviPage("admin/custom/group", "action=add&reset=1"); |
6a488035 TO |
42 | |
43 | //fill custom group title | |
44 | $customGroupTitle = 'custom_group' . substr(sha1(rand()), 0, 3); | |
45 | $this->click("title"); | |
46 | $this->type("title", $customGroupTitle); | |
47 | ||
48 | //custom group extends | |
49 | $this->click("extends[0]"); | |
50 | $this->select("extends[0]", "label=Contacts"); | |
51 | $this->click("//option[@value='Contact']"); | |
52 | $this->click("//form[@id='Group']/div[2]/div[3]/span[1]/input"); | |
53 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
22cef1b4 | 54 | $this->waitForElementPresent('newCustomField'); |
6a488035 TO |
55 | |
56 | //Is custom group created? | |
6c5f7368 | 57 | $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now."); |
22cef1b4 | 58 | |
6a488035 | 59 | //add custom field - alphanumeric text |
22cef1b4 | 60 | $this->waitForElementPresent('_qf_Field_cancel-bottom'); |
6a488035 TO |
61 | $textFieldLabel = 'test_text_field' . substr(sha1(rand()), 0, 3); |
62 | $this->click("header"); | |
63 | $this->type("label", $textFieldLabel); | |
64 | $this->click("_qf_Field_next_new-bottom"); | |
22cef1b4 | 65 | $this->waitForElementPresent('_qf_Field_cancel-bottom'); |
6a488035 TO |
66 | $this->click("data_type[0]"); |
67 | $this->select("data_type[0]", "value=0"); | |
68 | $this->click("//option[@value='0']"); | |
69 | $this->click("data_type[1]"); | |
70 | $this->select("data_type[1]", "label=CheckBox"); | |
71 | $this->click("//option[@value='CheckBox']"); | |
72 | ||
73 | $checkboxFieldLabel = 'test_checkbox' . substr(sha1(rand()), 0, 5); | |
74 | $this->type("label", $checkboxFieldLabel); | |
75 | $checkboxOptionLabel1 = 'check1' . substr(sha1(rand()), 0, 3); | |
76 | $this->type("option_label_1", $checkboxOptionLabel1); | |
77 | $this->type("option_value_1", "1"); | |
78 | $checkboxOptionLabel2 = 'check2' . substr(sha1(rand()), 0, 3); | |
79 | $this->type("option_label_2", $checkboxOptionLabel2); | |
80 | $this->type("option_value_2", "2"); | |
81 | $this->click("link=another choice"); | |
82 | $checkboxOptionLabel3 = 'check3' . substr(sha1(rand()), 0, 3); | |
83 | $this->type("option_label_3", $checkboxOptionLabel3); | |
84 | $this->type("option_value_3", "3"); | |
85 | $this->click("link=another choice"); | |
86 | $checkboxOptionLabel4 = 'check4' . substr(sha1(rand()), 0, 3); | |
87 | $this->type("option_label_4", $checkboxOptionLabel4); | |
88 | $this->type("option_value_4", "4"); | |
89 | ||
90 | //enter options per line | |
91 | $this->type("options_per_line", "2"); | |
92 | ||
93 | //enter pre help message | |
94 | $this->type("help_pre", "this is field pre help"); | |
95 | ||
96 | //enter post help message | |
97 | $this->type("help_post", "this field post help"); | |
98 | ||
99 | //Is searchable? | |
100 | $this->click("is_searchable"); | |
101 | ||
102 | //clicking save | |
103 | $this->click("_qf_Field_next_new-bottom"); | |
22cef1b4 | 104 | $this->waitForElementPresent('_qf_Field_cancel-bottom'); |
6a488035 | 105 | |
6a488035 TO |
106 | //create another custom field - Number Radio |
107 | $this->click("data_type[0]"); | |
108 | $this->select("data_type[0]", "value=2"); | |
109 | $this->click("//option[@value='2']"); | |
110 | $this->click("data_type[1]"); | |
111 | $this->select("data_type[1]", "value=Radio"); | |
112 | $this->click("//option[@value='Radio']"); | |
113 | ||
114 | $radioFieldLabel = 'test_radio' . substr(sha1(rand()), 0, 5); | |
115 | $this->type("label", $radioFieldLabel); | |
116 | $radioOptionLabel1 = 'radio1' . substr(sha1(rand()), 0, 3); | |
117 | $this->type("option_label_1", $radioOptionLabel1); | |
118 | $this->type("option_value_1", "1"); | |
119 | $radioOptionLabel2 = 'radio2' . substr(sha1(rand()), 0, 3); | |
120 | $this->type("option_label_2", $radioOptionLabel2); | |
121 | $this->type("option_value_2", "2"); | |
122 | ||
123 | //select options per line | |
124 | $this->type("options_per_line", "3"); | |
125 | ||
126 | //enter pre help msg | |
127 | $this->type("help_pre", "this is field pre help"); | |
128 | ||
129 | //enter post help msg | |
130 | $this->type("help_post", "this is field post help"); | |
131 | ||
132 | //Is searchable? | |
133 | $this->click("is_searchable"); | |
134 | ||
135 | //clicking save | |
22cef1b4 JP |
136 | $this->click("_qf_Field_done-bottom"); |
137 | $this->waitForElementPresent('newCustomField'); | |
6a488035 | 138 | |
6a488035 | 139 | //On New Individual contact form |
bb21371e RN |
140 | $this->openCiviPage("contact/add", "ct=Individual&reset=1"); |
141 | $this->assertElementContainsText('page-title', "New Individual"); | |
6a488035 TO |
142 | |
143 | //expand all tabs | |
144 | $this->click("expand"); | |
145 | $this->waitForElementPresent("address_1_street_address"); | |
146 | ||
147 | //verify custom group fields are present on new Individual Contact Form | |
bb21371e RN |
148 | $this->assertElementContainsText('customData', $textFieldLabel); |
149 | $this->assertElementContainsText('customData', $checkboxFieldLabel); | |
150 | $this->assertElementContainsText('customData', $checkboxOptionLabel1); | |
151 | $this->assertElementContainsText('customData', $checkboxOptionLabel2); | |
152 | $this->assertElementContainsText('customData', $checkboxOptionLabel3); | |
153 | $this->assertElementContainsText('customData', $checkboxOptionLabel4); | |
154 | $this->assertElementContainsText('customData', $radioFieldLabel); | |
155 | $this->assertElementContainsText('customData', $radioOptionLabel1); | |
156 | $this->assertElementContainsText('customData', $radioOptionLabel2); | |
6a488035 TO |
157 | |
158 | //On New Household contact form | |
bb21371e RN |
159 | $this->openCiviPage("contact/add", "ct=Household&reset=1"); |
160 | $this->assertElementContainsText('page-title', "New Household"); | |
6a488035 TO |
161 | |
162 | //expand all tabs | |
163 | $this->click("expand"); | |
164 | $this->waitForElementPresent("address_1_street_address"); | |
165 | ||
166 | //verify custom group fields are present on new household Contact Form | |
bb21371e RN |
167 | $this->assertElementContainsText('customData', $textFieldLabel); |
168 | $this->assertElementContainsText('customData', $checkboxFieldLabel); | |
169 | $this->assertElementContainsText('customData', $checkboxOptionLabel1); | |
170 | $this->assertElementContainsText('customData', $checkboxOptionLabel2); | |
171 | $this->assertElementContainsText('customData', $checkboxOptionLabel3); | |
172 | $this->assertElementContainsText('customData', $checkboxOptionLabel4); | |
173 | $this->assertElementContainsText('customData', $radioFieldLabel); | |
174 | $this->assertElementContainsText('customData', $radioOptionLabel1); | |
175 | $this->assertElementContainsText('customData', $radioOptionLabel2); | |
6a488035 TO |
176 | |
177 | //On New Organization contact form | |
bb21371e RN |
178 | $this->openCiviPage("contact/add", "ct=Organization&reset=1"); |
179 | $this->assertElementContainsText('page-title', "New Organization"); | |
6a488035 TO |
180 | |
181 | //expand all tabs | |
182 | $this->click("expand"); | |
183 | $this->waitForElementPresent("address_1_street_address"); | |
184 | ||
185 | //verify custom group fields are present on new Organization Contact Form | |
bb21371e RN |
186 | $this->assertElementContainsText('customData', $textFieldLabel); |
187 | $this->assertElementContainsText('customData', $checkboxFieldLabel); | |
188 | $this->assertElementContainsText('customData', $checkboxOptionLabel1); | |
189 | $this->assertElementContainsText('customData', $checkboxOptionLabel2); | |
190 | $this->assertElementContainsText('customData', $checkboxOptionLabel3); | |
191 | $this->assertElementContainsText('customData', $checkboxOptionLabel4); | |
192 | $this->assertElementContainsText('customData', $radioFieldLabel); | |
193 | $this->assertElementContainsText('customData', $radioOptionLabel1); | |
194 | $this->assertElementContainsText('customData', $radioOptionLabel2); | |
6a488035 | 195 | } |
96025800 | 196 | |
6a488035 | 197 | } |