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