3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Contact_TagSetSearchTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testTagSetSearch() {
35 $this->webtestLogin();
37 $tagSet1 = $this->_testAddTagSet();
38 $tagSet2 = $this->_testAddTagSet();
41 $contact1 = substr(sha1(rand()), 0, 7);
42 $this->webtestAddContact($contact1, "Anderson", "{$contact1}@example.com");
44 $this->click('css=li#tab_tag a');
45 $this->waitForElementPresent("token-input-contact_taglist_{$tagSet1}");
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);
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);
72 $contact2 = substr(sha1(rand()), 0, 7);
73 $this->webtestAddContact($contact2, "Anderson", "{$contact2}@example.com");
75 $this->click('css=li#tab_tag a');
76 $this->waitForElementPresent("token-input-contact_taglist_{$tagSet1}");
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);
89 // Go to Advance search.
90 $this->openCiviPage('contact/search/advanced', 'reset=1');
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}"));
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);
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");
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");
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);
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");
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");
122 $this->waitForTextPresent($tag2);
124 $this->click("_qf_Advanced_refresh");
125 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
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");
133 function _testAddTagSet() {
134 // Go to add tag set url.
135 $this->openCiviPage('admin/tag', 'action=add&reset=1&tagset=1');
137 // take a tagset name
138 $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
141 $this->type("name", $tagSetName);
144 $this->type("description", "Adding new tag set.");
146 // select used for contact
147 $this->select("used_for", "value=civicrm_contact");
150 $this->click("is_reserved");
153 $this->click("_qf_Tag_next");
154 $this->waitForPageToLoad($this->getTimeoutMsec());
156 // Is status message correct?
157 $this->waitForText('crm-notification-container', "The tag '$tagSetName' has been saved.");
160 $this->click("xpath=//table//tr/th[text()=\"ID\"]");
161 $this->waitForElementPresent("css=table.display tbody tr td");
164 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']");
166 $this->clickLink("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']");
168 return $this->urlArg('id');