3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}");
113 $this->waitForTextPresent($groupName);
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');
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');
121 $this->click("_qf_Advanced_refresh");
122 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
124 $this->assertTrue($this->isTextPresent("None found."));
126 // Go to advance search, check for 'Include' + 'OR' options.
127 $this->openCiviPage("contact/search/advanced", "reset=1");
129 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}");
130 $this->waitForTextPresent($groupName);
132 $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]");
134 $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');
135 $this->waitForTextPresent('Do not phone');
137 $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');
138 $this->waitForTextPresent('Do not email');
140 $this->click("_qf_Advanced_refresh");
141 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
142 $this->assertTrue($this->isTextPresent("2 Contacts"));
143 $this->assertTrue($this->isTextPresent("$lname1, $fname1"));
144 $this->assertTrue($this->isTextPresent("$lname2, $fname2"));
146 // Go to advance search, check for 'Include' + 'AND' options.
147 $this->openCiviPage("contact/search/advanced", "reset=1");
149 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}");
150 $this->waitForTextPresent($groupName);
152 $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]");
154 $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');
155 $this->waitForTextPresent('Do not phone');
157 $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');
158 $this->waitForTextPresent('Do not trade');
160 $this->select('privacy_operator', 'value=AND');
162 $this->click("_qf_Advanced_refresh");
163 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
164 $this->assertTrue($this->isTextPresent("1 Contact"));
165 $this->assertTrue($this->isTextPresent("$lname2, $fname2"));