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