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