3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contact_PrivacyOptionSearchTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testPrivacyOptionSearch() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
39 $this->open($this->sboxPath
);
41 // Logging in. Remember to wait for page to load. In most cases,
42 // you can rely on 30000 as the value that allows your test to pass, however,
43 // sometimes your test might fail because of this. In such cases, it's better to pick one element
44 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
45 // page contents loaded and you can continue your test execution.
46 $this->webtestLogin();
47 $this->waitForPageToLoad($this->getTimeoutMsec());
50 $this->open($this->sboxPath
. "civicrm/group/add?&reset=1");
51 $this->waitForElementPresent("_qf_Edit_upload");
53 $groupName = 'group_' . substr(sha1(rand()), 0, 7);
54 $this->type("title", $groupName);
57 $this->type("description", "Adding new group.");
59 // Check Access Control.
60 $this->click("group_type[1]");
63 $this->click("_qf_Edit_upload");
64 $this->waitForPageToLoad($this->getTimeoutMsec());
67 $fname1 = substr(sha1(rand()), 0, 7);
68 $lname1 = substr(sha1(rand()), 0, 7);
69 $this->open($this->sboxPath
. 'civicrm/contact/add?reset=1&ct=Individual');
70 $this->waitForElementPresent('_qf_Contact_upload_view-bottom');
71 $this->type('first_name', $fname1);
72 $this->type('last_name', $lname1);
73 $email1 = $fname1 . '@example.org';
74 $this->type('email_1_email', $email1);
76 //click 'Communication Preferences' Panel
77 $this->click("commPrefs");
78 $this->waitForElementPresent("preferred_mail_format");
79 $this->click("privacy_do_not_phone");
80 $this->click("privacy_do_not_email");
81 $this->click("privacy_do_not_mail");
82 $this->click("privacy_do_not_sms");
84 $this->click('_qf_Contact_upload_view-bottom');
85 $this->waitForPageToLoad($this->getTimeoutMsec());
87 // Add contact to the group.
88 $this->click("css=li#tab_group a");
89 $this->waitForElementPresent("group_id");
90 $this->select("group_id", "label=$groupName");
91 $this->click("_qf_GroupContact_next");
92 $this->waitForPageToLoad($this->getTimeoutMsec());
95 $fname2 = substr(sha1(rand()), 0, 7);
96 $lname2 = substr(sha1(rand()), 0, 7);
97 $this->open($this->sboxPath
. 'civicrm/contact/add?reset=1&ct=Individual');
98 $this->waitForElementPresent('_qf_Contact_upload_view-bottom');
99 $this->type('first_name', $fname2);
100 $this->type('last_name', $lname2);
101 $email2 = $fname2 . '@example.org';
102 $this->type('email_1_email', $email2);
104 //click 'Communication Preferences' Panel
105 $this->click("commPrefs");
106 $this->waitForElementPresent("preferred_mail_format");
107 $this->click("privacy_do_not_phone");
108 $this->click("privacy_do_not_email");
109 $this->click("privacy_do_not_trade");
111 $this->click('_qf_Contact_upload_view-bottom');
112 $this->waitForPageToLoad($this->getTimeoutMsec());
114 // Add contact to the group.
115 $this->click("css=li#tab_group a");
116 $this->waitForElementPresent("group_id");
117 $this->select("group_id", "label=$groupName");
118 $this->click("_qf_GroupContact_next");
119 $this->waitForPageToLoad($this->getTimeoutMsec());
121 // Go to advance search, check for 'Exclude' option.
122 $this->open($this->sboxPath
. "civicrm/contact/search/advanced?reset=1");
123 $this->waitForPageToLoad($this->getTimeoutMsec());
125 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}");
126 $this->waitForTextPresent($groupName);
128 $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');
129 $this->waitForTextPresent('Do not phone');
131 $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');
132 $this->waitForTextPresent('Do not email');
134 $this->click("_qf_Advanced_refresh");
135 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
137 $this->assertTrue($this->isTextPresent("No matches found"));
139 // Go to advance search, check for 'Include' + 'OR' options.
140 $this->open($this->sboxPath
. "civicrm/contact/search/advanced?reset=1");
141 $this->waitForPageToLoad($this->getTimeoutMsec());
143 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}");
144 $this->waitForTextPresent($groupName);
146 $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]");
148 $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');
149 $this->waitForTextPresent('Do not phone');
151 $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');
152 $this->waitForTextPresent('Do not email');
154 $this->click("_qf_Advanced_refresh");
155 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
156 $this->assertTrue($this->isTextPresent("2 Contacts"));
157 $this->assertTrue($this->isTextPresent("$lname1, $fname1"));
158 $this->assertTrue($this->isTextPresent("$lname2, $fname2"));
160 // Go to advance search, check for 'Include' + 'AND' options.
161 $this->open($this->sboxPath
. "civicrm/contact/search/advanced?reset=1");
162 $this->waitForPageToLoad($this->getTimeoutMsec());
164 $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}");
165 $this->waitForTextPresent($groupName);
167 $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]");
169 $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');
170 $this->waitForTextPresent('Do not phone');
172 $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');
173 $this->waitForTextPresent('Do not trade');
175 $this->select('privacy_operator', 'value=AND');
177 $this->click("_qf_Advanced_refresh");
178 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
179 $this->assertTrue($this->isTextPresent("1 Contact"));
180 $this->assertTrue($this->isTextPresent("$lname2, $fname2"));