3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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';
30 * Class WebTest_Contact_TagSetSearchTest
32 class WebTest_Contact_TagSetSearchTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testTagSetSearch() {
39 $this->webtestLogin();
41 $tagSet1 = $this->_testAddTagSet();
42 $tagSet2 = $this->_testAddTagSet();
45 $contact1 = substr(sha1(rand()), 0, 7);
46 $this->webtestAddContact($contact1, "Anderson", "{$contact1}@example.com");
48 $this->click('css=li#tab_tag a');
49 $this->waitForElementPresent("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input");
51 // Add tag1 for Individual 1
52 $tag1 = substr(sha1(rand()), 0, 5);
53 $this->click("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input");
54 $this->keyDown("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", " ");
55 $this->type("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", $tag1);
56 $this->typeKeys("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", $tag1);
57 // ...waiting for drop down with results to show up...
58 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
59 // ...need to use mouseDownAt on first result (which is a li element), click does not work
60 $this->clickAt("xpath=//div[@class='select2-result-label']");
61 $this->waitForTextPresent($tag1);
63 // Add tag2 for Individual 1
64 $tag2 = substr(sha1(rand()), 0, 5);
65 $this->click("xpath=//*[@id='contact_taglist_{$tagSet2}']/../div/ul/li[1]/input");
66 $this->keyDown("xpath=//*[@id='contact_taglist_{$tagSet2}']/../div/ul/li[1]/input", " ");
67 $this->type("xpath=//*[@id='contact_taglist_{$tagSet2}']/../div/ul/li[1]/input", $tag2);
68 $this->typeKeys("xpath=//*[@id='contact_taglist_{$tagSet2}']/../div/ul/li[1]/input", $tag2);
69 // ...waiting for drop down with results to show up...
70 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
71 // ...need to use mouseDownAt on first result (which is a li element), click does not work
72 $this->clickAt("xpath=//div[@class='select2-result-label']");
73 $this->waitForTextPresent($tag2);
76 $contact2 = substr(sha1(rand()), 0, 7);
77 $this->webtestAddContact($contact2, "Anderson", "{$contact2}@example.com");
79 $this->click('css=li#tab_tag a');
80 $this->waitForElementPresent("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input");
82 // Add tag1 for Individual 2
83 $this->click("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input");
84 $this->keyDown("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", " ");
85 $this->type("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", $tag1);
86 $this->typeKeys("xpath=//*[@id='contact_taglist_{$tagSet1}']/../div/ul/li[1]/input", $tag1);
87 // ...waiting for drop down with results to show up...
88 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
89 // ...need to use mouseDownAt on first result (which is a li element), click does not work
90 $this->clickAt("xpath=//div[@class='select2-result-label']");
91 $this->waitForTextPresent($tag1);
93 // Go to Advance search.
94 $this->openCiviPage('contact/search/advanced', 'reset=1');
96 // Check both the tagset.
97 $this->assertTrue($this->isElementPresent("contact_taglist_{$tagSet1}"));
98 $this->assertTrue($this->isElementPresent("contact_taglist_{$tagSet2}"));
100 // Search contact using tags.
101 $this->select2("contact_taglist_{$tagSet1}", $tag1, TRUE);
103 $this->waitForTextPresent($tag1);
104 $this->select2("contact_taglist_{$tagSet2}", $tag2, TRUE);
106 $this->waitForTextPresent($tag2);
108 $this->click("_qf_Advanced_refresh");
109 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
112 $this->assertElementContainsText('search-status', "2 Contacts");
113 $this->assertElementContainsText('css=.crm-search-results table.selector', "Anderson, $contact1");
114 $this->assertElementContainsText('css=.crm-search-results table.selector', "Anderson, $contact2");
120 public function _testAddTagSet() {
121 // Go to add tag set url.
122 $this->openCiviPage('admin/tag', 'action=add&reset=1&tagset=1');
124 // take a tagset name
125 $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
128 $this->type("name", $tagSetName);
131 $this->type("description", "Adding new tag set.");
133 // select used for contact
134 $this->select("used_for", "value=civicrm_contact");
137 $this->click("is_reserved");
140 $this->click("_qf_Tag_next");
141 $this->waitForPageToLoad($this->getTimeoutMsec());
143 // Is status message correct?
144 $this->waitForText('crm-notification-container', "The tag '$tagSetName' has been saved.");
147 $this->click("xpath=//div[@id='cat']/div/table/thead/tr/th[2]/div[text()='ID']");
148 $this->waitForElementPresent("css=table.display tbody tr td");
151 $this->assertTrue($this->isTextPresent($tagSetName), 'Missing text: ' . $tagSetName);
153 $tagid = explode('&id=', $this->getAttribute("xpath=//table[@class='display dataTable no-footer']/tbody//tr/td[1]/div[text()= '$tagSetName']/../../td[8]/span/a[text()= 'Edit']@href"));
154 $tagid = explode('&', $tagid[1]);