3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Contact_PrivacyOptionSearchTest
32 class WebTest_Contact_PrivacyOptionSearchTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testPrivacyOptionSearch() {
39 $this->webtestLogin();
40 $this->waitForPageToLoad($this->getTimeoutMsec());
43 $this->openCiviPage('group/add', 'reset=1', "_qf_Edit_upload");
45 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
46 $this->type("title", $groupName);
49 $this->type("description", "Adding new group.");
51 // Check Access Control.
52 $this->click("group_type[1]");
55 $this->click("_qf_Edit_upload");
56 $this->waitForPageToLoad($this->getTimeoutMsec());
59 $fname1 = substr(sha1(rand()), 0, 7);
60 $lname1 = substr(sha1(rand()), 0, 7);
61 $this->openCiviPage("contact/add", "reset=1&ct=Individual", '_qf_Contact_upload_view-bottom');
62 $this->type('first_name', $fname1);
63 $this->type('last_name', $lname1);
64 $email1 = $fname1 . '@example.org';
65 $this->type('email_1_email', $email1);
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");
75 $this->click('_qf_Contact_upload_view-bottom');
76 $this->waitForPageToLoad($this->getTimeoutMsec());
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");
85 $fname2 = substr(sha1(rand()), 0, 7);
86 $lname2 = substr(sha1(rand()), 0, 7);
87 $this->openCiviPage("contact/add", "reset=1&ct=Individual", '_qf_Contact_upload_view-bottom');
88 $this->type('first_name', $fname2);
89 $this->type('last_name', $lname2);
90 $email2 = $fname2 . '@example.org';
91 $this->type('email_1_email', $email2);
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");
100 $this->click('_qf_Contact_upload_view-bottom');
101 $this->waitForPageToLoad($this->getTimeoutMsec());
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");
109 // Go to advance search, check for 'Exclude' option.
110 $this->openCiviPage("contact/search/advanced", "reset=1");
112 $this->select("group", "label={$groupName}");
113 $this->waitForTextPresent($groupName);
115 $this->multiselect2('privacy_options', array('Do not phone', 'Do not email'));
117 $this->click("_qf_Advanced_refresh");
118 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
120 $this->assertTrue($this->isTextPresent("None found."));
122 // Go to advance search, check for 'Include' + 'OR' options.
123 $this->openCiviPage("contact/search/advanced", "reset=1");
125 $this->select("group", "label={$groupName}");
126 $this->waitForTextPresent($groupName);
128 $this->click("CIVICRM_QFID_2_privacy_toggle");
130 $this->multiselect2('privacy_options', array('Do not phone', 'Do not email'));
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"));
138 // Go to advance search, check for 'Include' + 'AND' options.
139 $this->openCiviPage("contact/search/advanced", "reset=1");
141 $this->select("group", "label={$groupName}");
142 $this->waitForTextPresent($groupName);
144 $this->click("CIVICRM_QFID_2_privacy_toggle");
146 $this->multiselect2('privacy_options', array('Do not phone', 'Do not trade'));
148 $this->select('privacy_operator', 'value=AND');
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"));