Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | ||
27 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class WebTest_Contact_TagSetSearchTest extends CiviSeleniumTestCase { | |
30 | ||
31 | protected function setUp() { | |
32 | parent::setUp(); | |
33 | } | |
34 | ||
35 | function testTagSetSearch() { | |
36 | $this->open($this->sboxPath); | |
37 | $this->webtestLogin(); | |
38 | ||
39 | ||
40 | $tagSet1 = $this->_testAddTagSet(); | |
41 | $tagSet2 = $this->_testAddTagSet(); | |
42 | ||
43 | // Individual 1 | |
44 | $contact1 = substr(sha1(rand()), 0, 7); | |
45 | $this->webtestAddContact($contact1, "Anderson", "{$contact1}@example.com"); | |
46 | ||
47 | $this->click('css=li#tab_tag a'); | |
48 | $this->waitForElementPresent("token-input-contact_taglist_{$tagSet1}"); | |
49 | ||
50 | // Add tag1 for Individual 1 | |
51 | $tag1 = substr(sha1(rand()), 0, 5); | |
52 | $this->click("css=input#token-input-contact_taglist_{$tagSet1}"); | |
53 | $this->type("css=input#token-input-contact_taglist_{$tagSet1}", $tag1); | |
54 | $this->typeKeys("css=input#token-input-contact_taglist_{$tagSet1}", $tag1); | |
55 | // ...waiting for drop down with results to show up... | |
56 | $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); | |
57 | $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook"); | |
58 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
59 | $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook"); | |
60 | $this->waitForTextPresent($tag1); | |
61 | ||
62 | // Add tag2 for Individual 1 | |
63 | $tag2 = substr(sha1(rand()), 0, 5); | |
64 | $this->click("css=input#token-input-contact_taglist_{$tagSet2}"); | |
65 | $this->type("css=input#token-input-contact_taglist_{$tagSet2}", $tag2); | |
66 | $this->typeKeys("css=input#token-input-contact_taglist_{$tagSet2}", $tag2); | |
67 | // ...waiting for drop down with results to show up... | |
68 | $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); | |
69 | $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook"); | |
70 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
71 | $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook"); | |
72 | $this->waitForTextPresent($tag2); | |
73 | ||
74 | ||
75 | // Individual 2 | |
76 | $contact2 = substr(sha1(rand()), 0, 7); | |
77 | $this->webtestAddContact($contact2, "Anderson", "{$contact2}@example.com"); | |
78 | ||
79 | $this->click('css=li#tab_tag a'); | |
80 | $this->waitForElementPresent("token-input-contact_taglist_{$tagSet1}"); | |
81 | ||
82 | // Add tag1 for Individual 2 | |
83 | $this->click("css=input#token-input-contact_taglist_{$tagSet1}"); | |
84 | $this->type("css=input#token-input-contact_taglist_{$tagSet1}", $tag1); | |
85 | $this->typeKeys("css=input#token-input-contact_taglist_{$tagSet1}", $tag1); | |
86 | // ...waiting for drop down with results to show up... | |
87 | $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); | |
88 | $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook"); | |
89 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
90 | $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook"); | |
91 | $this->waitForTextPresent($tag1); | |
92 | ||
93 | ||
94 | // Go to Advance search. | |
d8bd5fb9 | 95 | $this->openCiviPage('contact/search/advanced', 'reset=1'); |
6a488035 TO |
96 | |
97 | // Check both the tagset. | |
98 | $this->assertTrue($this->isElementPresent("token-input-contact_taglist_{$tagSet1}")); | |
99 | $this->assertTrue($this->isElementPresent("token-input-contact_taglist_{$tagSet2}")); | |
100 | ||
101 | // Search contact using tags. | |
102 | $this->click("css=input#token-input-contact_taglist_{$tagSet1}"); | |
103 | $this->type("css=input#token-input-contact_taglist_{$tagSet1}", $tag1); | |
104 | $this->typeKeys("css=input#token-input-contact_taglist_{$tagSet1}", $tag1); | |
105 | ||
106 | // ...waiting for drop down with results to show up... | |
107 | $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); | |
108 | $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook"); | |
109 | ||
110 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
111 | $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook"); | |
112 | ||
113 | $this->waitForTextPresent($tag1); | |
114 | $this->click("css=input#token-input-contact_taglist_{$tagSet2}"); | |
115 | $this->type("css=input#token-input-contact_taglist_{$tagSet2}", $tag2); | |
116 | $this->click("css=input#token-input-contact_taglist_{$tagSet2}"); | |
117 | $this->type("css=input#token-input-contact_taglist_{$tagSet2}", $tag2); | |
118 | $this->typeKeys("css=input#token-input-contact_taglist_{$tagSet2}", $tag2); | |
119 | ||
120 | // ...waiting for drop down with results to show up... | |
121 | $this->waitForElementPresent("css=div.token-input-dropdown-facebook"); | |
122 | $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook"); | |
123 | ||
124 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
125 | $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook"); | |
126 | ||
127 | $this->waitForTextPresent($tag2); | |
128 | ||
129 | $this->click("_qf_Advanced_refresh"); | |
130 | $this->waitForPageToLoad(2 * $this->getTimeoutMsec()); | |
131 | ||
132 | // Check result. | |
d8bd5fb9 RN |
133 | $this->assertElementContainsText('search-status', "2 Contacts"); |
134 | $this->assertElementContainsText('css=.crm-search-results table.selector', "Anderson, $contact1"); | |
135 | $this->assertElementContainsText('css=.crm-search-results table.selector', "Anderson, $contact2"); | |
6a488035 TO |
136 | } |
137 | ||
138 | function _testAddTagSet() { | |
139 | // Go to add tag set url. | |
d8bd5fb9 | 140 | $this->openCiviPage('admin/tag', 'action=add&reset=1&tagset=1'); |
6a488035 TO |
141 | |
142 | // take a tagset name | |
143 | $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7); | |
144 | ||
145 | // fill tagset name | |
146 | $this->type("name", $tagSetName); | |
147 | ||
148 | // fill description | |
149 | $this->type("description", "Adding new tag set."); | |
150 | ||
151 | // select used for contact | |
152 | $this->select("used_for", "value=civicrm_contact"); | |
153 | ||
154 | // check reserved | |
155 | $this->click("is_reserved"); | |
156 | ||
157 | // Clicking save. | |
158 | $this->click("_qf_Tag_next"); | |
159 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
160 | ||
161 | // Is status message correct? | |
d8bd5fb9 | 162 | $this->assertElementContainsText('crm-notification-container', "The tag '$tagSetName' has been saved."); |
6a488035 TO |
163 | |
164 | // sort by ID desc | |
165 | $this->click("xpath=//table//tr/th[text()=\"ID\"]"); | |
166 | $this->waitForElementPresent("css=table.display tbody tr td"); | |
167 | ||
168 | // verify text | |
169 | $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']"); | |
170 | ||
171 | $this->click("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']"); | |
172 | ||
173 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
174 | ||
175 | // Get contact id from url. | |
176 | $matches = array(); | |
177 | preg_match('/id=([0-9]+)/', $this->getLocation(), $matches); | |
178 | ||
179 | return $matches[1]; | |
180 | } | |
181 | } | |
182 |