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