Global webtest cleanup
[civicrm-core.git] / tests / phpunit / WebTest / Contact / PrivacyOptionSearchTest.php
CommitLineData
6a488035
TO
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
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class WebTest_Contact_PrivacyOptionSearchTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testPrivacyOptionSearch() {
6a488035
TO
36 $this->webtestLogin();
37 $this->waitForPageToLoad($this->getTimeoutMsec());
38
39 // Add new group.
42daf119 40 $this->openCiviPage('group/add', 'reset=1', "_qf_Edit_upload");
6a488035
TO
41
42 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
43 $this->type("title", $groupName);
44
45 // Fill description.
46 $this->type("description", "Adding new group.");
47
48 // Check Access Control.
49 $this->click("group_type[1]");
50
51 // Clicking save.
52 $this->click("_qf_Edit_upload");
53 $this->waitForPageToLoad($this->getTimeoutMsec());
54
55 // Add Contact1.
56 $fname1 = substr(sha1(rand()), 0, 7);
57 $lname1 = substr(sha1(rand()), 0, 7);
42daf119 58 $this->openCiviPage("contact/add", "reset=1&ct=Individual", '_qf_Contact_upload_view-bottom');
6a488035
TO
59 $this->type('first_name', $fname1);
60 $this->type('last_name', $lname1);
61 $email1 = $fname1 . '@example.org';
62 $this->type('email_1_email', $email1);
63
64 //click 'Communication Preferences' Panel
65 $this->click("commPrefs");
66 $this->waitForElementPresent("preferred_mail_format");
67 $this->click("privacy_do_not_phone");
68 $this->click("privacy_do_not_email");
69 $this->click("privacy_do_not_mail");
70 $this->click("privacy_do_not_sms");
71
72 $this->click('_qf_Contact_upload_view-bottom');
73 $this->waitForPageToLoad($this->getTimeoutMsec());
74
75 // Add contact to the group.
76 $this->click("css=li#tab_group a");
77 $this->waitForElementPresent("group_id");
78 $this->select("group_id", "label=$groupName");
79 $this->click("_qf_GroupContact_next");
80 $this->waitForPageToLoad($this->getTimeoutMsec());
81
82 // Add Contact2.
83 $fname2 = substr(sha1(rand()), 0, 7);
84 $lname2 = substr(sha1(rand()), 0, 7);
42daf119 85 $this->openCiviPage("contact/add", "reset=1&ct=Individual", '_qf_Contact_upload_view-bottom');
6a488035
TO
86 $this->type('first_name', $fname2);
87 $this->type('last_name', $lname2);
88 $email2 = $fname2 . '@example.org';
89 $this->type('email_1_email', $email2);
90
91 //click 'Communication Preferences' Panel
92 $this->click("commPrefs");
93 $this->waitForElementPresent("preferred_mail_format");
94 $this->click("privacy_do_not_phone");
95 $this->click("privacy_do_not_email");
96 $this->click("privacy_do_not_trade");
97
98 $this->click('_qf_Contact_upload_view-bottom');
99 $this->waitForPageToLoad($this->getTimeoutMsec());
100
101 // Add contact to the group.
102 $this->click("css=li#tab_group a");
103 $this->waitForElementPresent("group_id");
104 $this->select("group_id", "label=$groupName");
105 $this->click("_qf_GroupContact_next");
106 $this->waitForPageToLoad($this->getTimeoutMsec());
107
108 // Go to advance search, check for 'Exclude' option.
109 $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1");
110 $this->waitForPageToLoad($this->getTimeoutMsec());
111
112 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}");
113 $this->waitForTextPresent($groupName);
114
115 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_phone');
116 $this->waitForTextPresent('Do not phone');
117
118 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_email');
119 $this->waitForTextPresent('Do not email');
120
121 $this->click("_qf_Advanced_refresh");
122 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
123
124 $this->assertTrue($this->isTextPresent("No matches found"));
125
126 // Go to advance search, check for 'Include' + 'OR' options.
127 $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1");
128 $this->waitForPageToLoad($this->getTimeoutMsec());
129
130 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}");
131 $this->waitForTextPresent($groupName);
132
133 $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]");
134
135 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_phone');
136 $this->waitForTextPresent('Do not phone');
137
138 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_email');
139 $this->waitForTextPresent('Do not email');
140
141 $this->click("_qf_Advanced_refresh");
142 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
143 $this->assertTrue($this->isTextPresent("2 Contacts"));
144 $this->assertTrue($this->isTextPresent("$lname1, $fname1"));
145 $this->assertTrue($this->isTextPresent("$lname2, $fname2"));
146
147 // Go to advance search, check for 'Include' + 'AND' options.
148 $this->open($this->sboxPath . "civicrm/contact/search/advanced?reset=1");
149 $this->waitForPageToLoad($this->getTimeoutMsec());
150
151 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}");
152 $this->waitForTextPresent($groupName);
153
154 $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]");
155
156 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_phone');
157 $this->waitForTextPresent('Do not phone');
158
159 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[2]/td[1]//select[1]", 'value=do_not_trade');
160 $this->waitForTextPresent('Do not trade');
161
162 $this->select('privacy_operator', 'value=AND');
163
164 $this->click("_qf_Advanced_refresh");
165 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
166 $this->assertTrue($this->isTextPresent("1 Contact"));
167 $this->assertTrue($this->isTextPresent("$lname2, $fname2"));
168 }
169}
170