Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class 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"); | |
6a488035 TO |
79 | |
80 | // Add Contact2. | |
81 | $fname2 = substr(sha1(rand()), 0, 7); | |
82 | $lname2 = substr(sha1(rand()), 0, 7); | |
42daf119 | 83 | $this->openCiviPage("contact/add", "reset=1&ct=Individual", '_qf_Contact_upload_view-bottom'); |
6a488035 TO |
84 | $this->type('first_name', $fname2); |
85 | $this->type('last_name', $lname2); | |
86 | $email2 = $fname2 . '@example.org'; | |
87 | $this->type('email_1_email', $email2); | |
88 | ||
89 | //click 'Communication Preferences' Panel | |
90 | $this->click("commPrefs"); | |
91 | $this->waitForElementPresent("preferred_mail_format"); | |
92 | $this->click("privacy_do_not_phone"); | |
93 | $this->click("privacy_do_not_email"); | |
94 | $this->click("privacy_do_not_trade"); | |
95 | ||
96 | $this->click('_qf_Contact_upload_view-bottom'); | |
97 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
98 | ||
99 | // Add contact to the group. | |
100 | $this->click("css=li#tab_group a"); | |
101 | $this->waitForElementPresent("group_id"); | |
102 | $this->select("group_id", "label=$groupName"); | |
103 | $this->click("_qf_GroupContact_next"); | |
6a488035 TO |
104 | |
105 | // Go to advance search, check for 'Exclude' option. | |
071a6d2e | 106 | $this->openCiviPage("contact/search/advanced", "reset=1"); |
6a488035 TO |
107 | |
108 | $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}"); | |
109 | $this->waitForTextPresent($groupName); | |
110 | ||
111 | $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'); | |
112 | $this->waitForTextPresent('Do not phone'); | |
113 | ||
114 | $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'); | |
115 | $this->waitForTextPresent('Do not email'); | |
116 | ||
117 | $this->click("_qf_Advanced_refresh"); | |
118 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
119 | ||
120 | $this->assertTrue($this->isTextPresent("No matches found")); | |
121 | ||
122 | // Go to advance search, check for 'Include' + 'OR' options. | |
071a6d2e | 123 | $this->openCiviPage("contact/search/advanced", "reset=1"); |
6a488035 TO |
124 | |
125 | $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}"); | |
126 | $this->waitForTextPresent($groupName); | |
127 | ||
128 | $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]"); | |
129 | ||
130 | $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'); | |
131 | $this->waitForTextPresent('Do not phone'); | |
132 | ||
133 | $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'); | |
134 | $this->waitForTextPresent('Do not email'); | |
135 | ||
136 | $this->click("_qf_Advanced_refresh"); | |
137 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
138 | $this->assertTrue($this->isTextPresent("2 Contacts")); | |
139 | $this->assertTrue($this->isTextPresent("$lname1, $fname1")); | |
140 | $this->assertTrue($this->isTextPresent("$lname2, $fname2")); | |
141 | ||
142 | // Go to advance search, check for 'Include' + 'AND' options. | |
071a6d2e | 143 | $this->openCiviPage("contact/search/advanced", "reset=1"); |
6a488035 TO |
144 | |
145 | $this->select("xpath=//form[@id='Advanced']//table[1]/tbody/tr[2]/td[2]//select[1]", "label={$groupName}"); | |
146 | $this->waitForTextPresent($groupName); | |
147 | ||
148 | $this->click("xpath=//form[@id='Advanced']//table[1]/tbody/tr[5]/td[1]/table[1]/tbody/tr[1]/td[1]//input[2]"); | |
149 | ||
150 | $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'); | |
151 | $this->waitForTextPresent('Do not phone'); | |
152 | ||
153 | $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'); | |
154 | $this->waitForTextPresent('Do not trade'); | |
155 | ||
156 | $this->select('privacy_operator', 'value=AND'); | |
157 | ||
158 | $this->click("_qf_Advanced_refresh"); | |
159 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
160 | $this->assertTrue($this->isTextPresent("1 Contact")); | |
161 | $this->assertTrue($this->isTextPresent("$lname2, $fname2")); | |
162 | } | |
163 | } | |
164 |