e1069955 |
1 | <?php |
2 | /* |
3 | +--------------------------------------------------------------------+ |
4 | | CiviCRM version 4.3 | |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | |
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 | |
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
29 | class WebTest_Admin_CustomAddTestSameField extends CiviSeleniumTestCase { |
30 | |
31 | protected function setUp() { |
32 | parent::setUp(); |
33 | } |
34 | |
35 | function testCustomSameFieldAdd() { |
36 | $this->open($this->sboxPath); |
37 | $this->webtestLogin(); |
b6708aeb |
38 | |
e1069955 |
39 | $this->_testCustomAdd(); |
40 | $this->_testCustomAdd(); |
41 | } |
b6708aeb |
42 | |
e1069955 |
43 | function _testCustomAdd() { |
44 | //CRM-7564 : Different gropus can contain same custom fields |
b6708aeb |
45 | $this->open($this->sboxPath . "civicrm/admin/custom/group?action=add&reset=1"); |
e1069955 |
46 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
47 | |
48 | //fill custom group title |
49 | $customGroupTitle = 'custom_group' . substr(sha1(rand()), 0, 3); |
50 | $this->click("title"); |
51 | $this->type("title", $customGroupTitle); |
b6708aeb |
52 | |
e1069955 |
53 | //custom group extends |
54 | $this->click("extends[0]"); |
55 | $this->select("extends[0]", "label=Contacts"); |
56 | $this->click("//option[@value='Contact']"); |
57 | $this->click("//form[@id='Group']/div[2]/div[3]/span[1]/input"); |
58 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
b6708aeb |
59 | |
e1069955 |
60 | //Is custom group created? |
61 | $this->assertTrue($this->isTextPresent("Your custom field set '$customGroupTitle' has been added. You can add custom fields now.")); |
62 | //add custom field - alphanumeric text |
63 | $textFieldLabel = 'test_text_field'; |
64 | $this->click("header"); |
65 | $this->type("label", $textFieldLabel); |
66 | $this->click("_qf_Field_next_new-bottom"); |
67 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
68 | $this->click("data_type[0]"); |
69 | $this->select("data_type[0]", "value=0"); |
70 | $this->click("//option[@value='0']"); |
71 | $this->click("data_type[1]"); |
72 | $this->select("data_type[1]", "label=CheckBox"); |
73 | $this->click("//option[@value='CheckBox']"); |
b6708aeb |
74 | |
e1069955 |
75 | $checkboxFieldLabel = 'test_checkbox'; |
76 | $this->type("label", $checkboxFieldLabel); |
77 | $checkboxOptionLabel1 = 'check1'; |
78 | $this->type("option_label_1", $checkboxOptionLabel1); |
79 | $this->type("option_value_1", "1"); |
80 | $checkboxOptionLabel2 = 'check2'; |
81 | $this->type("option_label_2", $checkboxOptionLabel2); |
82 | $this->type("option_value_2", "2"); |
83 | $this->click("link=another choice"); |
84 | $checkboxOptionLabel3 = 'check3'; |
85 | $this->type("option_label_3", $checkboxOptionLabel3); |
86 | $this->type("option_value_3", "3"); |
87 | $this->click("link=another choice"); |
88 | $checkboxOptionLabel4 = 'check4'; |
89 | $this->type("option_label_4", $checkboxOptionLabel4); |
90 | $this->type("option_value_4", "4"); |
b6708aeb |
91 | |
e1069955 |
92 | //enter options per line |
93 | $this->type("options_per_line", "2"); |
b6708aeb |
94 | |
e1069955 |
95 | //enter pre help message |
96 | $this->type("help_pre", "this is field pre help"); |
97 | |
98 | //enter post help message |
99 | $this->type("help_post", "this field post help"); |
b6708aeb |
100 | |
e1069955 |
101 | //Is searchable? |
102 | $this->click("is_searchable"); |
b6708aeb |
103 | |
e1069955 |
104 | //clicking save |
105 | $this->click("_qf_Field_next_new-bottom"); |
106 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
b6708aeb |
107 | |
e1069955 |
108 | //Is custom field created? |
109 | $this->assertTrue($this->isTextPresent("Your custom field '$checkboxFieldLabel' has been saved.")); |
b6708aeb |
110 | |
e1069955 |
111 | //add custom field - alphanumeric text |
112 | $textFieldLabel = 'test_text_field'; |
113 | $this->click("header"); |
114 | $this->type("label", $textFieldLabel); |
115 | $this->click("_qf_Field_next_new-bottom"); |
b6708aeb |
116 | |
e1069955 |
117 | // Same group will not contain same custome fields so will show error for this field : |
118 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
119 | $this->click("data_type[0]"); |
120 | $this->select("data_type[0]", "value=0"); |
121 | $this->click("//option[@value='0']"); |
122 | $this->click("data_type[1]"); |
123 | $this->select("data_type[1]", "label=CheckBox"); |
124 | $this->click("//option[@value='CheckBox']"); |
125 | //Is custom field created |
126 | $this->assertTrue($this->isTextPresent("Custom field '$textFieldLabel' already exists in Database.")); |
b6708aeb |
127 | |
e1069955 |
128 | //create another custom field - Number Radio |
129 | $this->click("data_type[0]"); |
130 | $this->select("data_type[0]", "value=2"); |
131 | $this->click("//option[@value='2']"); |
132 | $this->click("data_type[1]"); |
133 | $this->select("data_type[1]", "value=Radio"); |
134 | $this->click("//option[@value='Radio']"); |
b6708aeb |
135 | |
e1069955 |
136 | $radioFieldLabel = 'test_radio'; |
137 | $this->type("label", $radioFieldLabel); |
138 | $radioOptionLabel1 = 'radio1'; |
139 | $this->type("option_label_1", $radioOptionLabel1); |
140 | $this->type("option_value_1", "1"); |
141 | $radioOptionLabel2 = 'radio2'; |
142 | $this->type("option_label_2", $radioOptionLabel2); |
143 | $this->type("option_value_2", "2"); |
b6708aeb |
144 | |
e1069955 |
145 | //select options per line |
146 | $this->type("options_per_line", "3"); |
b6708aeb |
147 | |
e1069955 |
148 | //enter pre help msg |
149 | $this->type("help_pre", "this is field pre help"); |
b6708aeb |
150 | |
e1069955 |
151 | //enter post help msg |
152 | $this->type("help_post", "this is field post help"); |
b6708aeb |
153 | |
e1069955 |
154 | //Is searchable? |
155 | $this->click("is_searchable"); |
b6708aeb |
156 | |
e1069955 |
157 | //clicking save |
158 | $this->click("_qf_Field_next-bottom"); |
159 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
b6708aeb |
160 | |
e1069955 |
161 | //Is custom field created |
b6708aeb |
162 | $this->assertTrue($this->isTextPresent("Your custom field '$radioFieldLabel' has been saved.")); |
163 | |
164 | } |
e1069955 |
165 | } |
166 | |