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