3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
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_ContactTagTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testTagAContact() {
35 $this->webtestLogin();
37 $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next");
40 $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
43 $this->type("name", $tagName);
46 $this->type("description", "Adding new tag.");
48 // select used for contact
49 $this->select("used_for", "value=civicrm_contact");
52 $this->click("is_reserved");
55 $this->click("_qf_Tag_next");
56 $this->waitForPageToLoad($this->getTimeoutMsec());
58 // Is status message correct?
59 $this->assertTrue($this->isTextPresent("The tag '$tagName' has been saved."));
62 // We're using Quick Add block on the main page for this.
63 $firstName = substr(sha1(rand()), 0, 7);
64 $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
67 $this->click("css=li#tab_tag a");
68 $this->waitForElementPresent("css=div#tagtree");
70 // check tag we have created
71 $this->click("xpath=//ul/li/label[text()=\"$tagName\"]");
72 $this->waitForElementPresent("css=.success");
74 // Is status message correct?
75 $this->assertTrue($this->isTextPresent("Saved"));
78 function testTagSetContact() {
79 $this->webtestLogin();
81 $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1");
84 $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
87 $this->type("name", $tagSetName);
90 $this->type("description", "Adding new tag set.");
92 // select used for contact
93 $this->select("used_for", "value=civicrm_contact");
96 $this->click("is_reserved");
99 $this->click("_qf_Tag_next");
100 $this->waitForPageToLoad($this->getTimeoutMsec());
102 // Is status message correct?
103 $this->assertTrue($this->isTextPresent("The tag '$tagSetName' has been saved."));
106 // We're using Quick Add block on the main page for this.
107 $firstName = substr(sha1(rand()), 0, 7);
108 $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
111 $this->click("css=li#tab_tag a");
112 $this->waitForElementPresent("css=div#tagtree");
114 //add Tagset to contact
115 $this->click("//div[@id='Tag']/div[3]/div[1]/ul/li[1]/input");
116 $this->type("//div[@id='Tag']/div[3]/div[1]/ul/li[1]/input", 'tagset1');
117 $this->typeKeys("//div[@id='Tag']/div[3]/div[1]/ul/li[1]/input", 'tagset1');
119 // ...waiting for drop down with results to show up...
120 $this->waitForElementPresent("css=div.token-input-dropdown-facebook");
121 $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook");
123 // ...need to use mouseDownAt on first result (which is a li element), click does not work
124 $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook");
126 $this->waitForElementPresent("//div[@id='Tag']/div[3]/div[1]/ul/li[1]/span");
127 $this->click("//div[@id='Tag']/div[3]/div[1]/ul/li[2]/input");
128 $this->type("//div[@id='Tag']/div[3]/div[1]/ul/li[2]/input", 'tagset2');
129 $this->typeKeys("//div[@id='Tag']/div[3]/div[1]/ul/li[2]/input", 'tagset2');
131 // ...waiting for drop down with results to show up...
132 $this->waitForElementPresent("css=div.token-input-dropdown-facebook");
133 $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook");
135 // ...need to use mouseDownAt on first result (which is a li element), click does not work
136 $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook");
138 $this->click("//div[@id='Tag']/div[3]/div[1]/ul/li");
140 // Type search name in autocomplete.
141 $this->click("css=input#sort_name_navigation");
142 $this->type("css=input#sort_name_navigation", $firstName);
143 $this->typeKeys("css=input#sort_name_navigation", $firstName);
145 // Wait for result list.
146 $this->waitForElementPresent("css=div.ac_results-inner li");
148 // Visit contact summary page.
149 $this->click("css=div.ac_results-inner li");
150 $this->waitForPageToLoad($this->getTimeoutMsec());
151 $this->assertTrue($this->isTextPresent("tagset1, tagset2"));