phpcs - Fix error, "Expected 1 newline at end of file; XXX found".
[civicrm-core.git] / tests / phpunit / WebTest / Admin / CustomAddTestSameField.php
CommitLineData
e1069955 1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
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
28require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
29
30/**
31 * Class WebTest_Admin_CustomAddTestSameField
32 */
e1069955 33class WebTest_Admin_CustomAddTestSameField extends CiviSeleniumTestCase {
34
35 protected function setUp() {
36 parent::setUp();
37 }
38
00be9182 39 public function testCustomSameFieldAdd() {
e1069955 40 $this->open($this->sboxPath);
41 $this->webtestLogin();
b6708aeb 42
e1069955 43 $this->_testCustomAdd();
44 $this->_testCustomAdd();
45 }
b6708aeb 46
00be9182 47 public function _testCustomAdd() {
e1069955 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']");
39a2888d 61 $this->clickLink("//form[@id='Group']/div[2]/div[3]/span[1]/input");
b6708aeb 62
e1069955 63 //Is custom group created?
39a2888d 64 $this->waitForText('crm-notification-container', "Your custom field set '$customGroupTitle' has been added. You can add custom fields now.");
48b420d7 65
39a2888d 66 $gid = $this->urlArg('gid');
48b420d7 67
e1069955 68 //add custom field - alphanumeric text
39a2888d 69 $this->openCiviPage('admin/custom/group/field/add', "reset=1&action=add&gid=$gid");
e1069955 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']");
b6708aeb 81
e1069955 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");
b6708aeb 98
e1069955 99 //enter options per line
100 $this->type("options_per_line", "2");
b6708aeb 101
e1069955 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");
b6708aeb 107
e1069955 108 //Is searchable?
109 $this->click("is_searchable");
b6708aeb 110
e1069955 111 //clicking save
39a2888d 112 $this->clickLink("_qf_Field_next_new-bottom");
b6708aeb 113
e1069955 114 //Is custom field created?
39a2888d 115 $this->waitForText('crm-notification-container', "Custom field '$checkboxFieldLabel' has been saved.");
b6708aeb 116
e1069955 117 //add custom field - alphanumeric text
118 $textFieldLabel = 'test_text_field';
119 $this->click("header");
120 $this->type("label", $textFieldLabel);
39a2888d 121 $this->clickLink("_qf_Field_next_new-bottom");
b6708aeb 122
e1069955 123 // Same group will not contain same custome fields so will show error for this field :
e1069955 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
39a2888d 131 $this->waitForText('crm-notification-container', "Custom field '$textFieldLabel' already exists in Database.");
b6708aeb 132
e1069955 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']");
b6708aeb 140
e1069955 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");
b6708aeb 149
e1069955 150 //select options per line
151 $this->type("options_per_line", "3");
b6708aeb 152
e1069955 153 //enter pre help msg
154 $this->type("help_pre", "this is field pre help");
b6708aeb 155
e1069955 156 //enter post help msg
157 $this->type("help_post", "this is field post help");
b6708aeb 158
e1069955 159 //Is searchable?
160 $this->click("is_searchable");
b6708aeb 161
e1069955 162 //clicking save
39a2888d 163 $this->clickLink("_qf_Field_done-bottom");
b6708aeb 164
e1069955 165 //Is custom field created
39a2888d 166 $this->waitForText('crm-notification-container', "Custom field '$radioFieldLabel' has been saved.");
b6708aeb 167
168 }
e1069955 169}