3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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_ContactTagTest
32 class WebTest_Contact_ContactTagTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 function testTagAContact() {
39 $this->webtestLogin();
41 $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next");
44 $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
47 $this->type("name", $tagName);
50 $this->type("description", "Adding new tag.");
52 // select used for contact
53 $this->select("used_for", "value=civicrm_contact");
56 $this->click("is_reserved");
59 $this->click("_qf_Tag_next");
60 $this->waitForPageToLoad($this->getTimeoutMsec());
62 // Is status message correct?
63 $this->waitForText('crm-notification-container', "The tag '$tagName' has been saved.");
66 // We're using Quick Add block on the main page for this.
67 $firstName = substr(sha1(rand()), 0, 7);
68 $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
71 $this->click("css=li#tab_tag a");
72 $this->waitForElementPresent("css=div#tagtree");
74 // check tag we have created
75 $this->click("xpath=//ul/li/label[text()=\"$tagName\"]");
76 $this->waitForElementPresent("css=.success");
78 // Is status message correct?
79 $this->waitForText('crm-notification-container', "Saved");
82 function testTagSetContact() {
83 $this->webtestLogin();
85 $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1");
88 $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
91 $this->type("name", $tagSetName);
94 $this->type("description", "Adding new tag set.");
96 // select used for contact
97 $this->select("used_for", "value=civicrm_contact");
100 $this->click("is_reserved");
103 $this->click("_qf_Tag_next");
104 $this->waitForPageToLoad($this->getTimeoutMsec());
106 // Is status message correct?
107 $this->waitForText('crm-notification-container', "The tag '$tagSetName' has been saved.");
110 // We're using Quick Add block on the main page for this.
111 $firstName = substr(sha1(rand()), 0, 7);
112 $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
115 $this->click("css=li#tab_tag a");
116 $this->waitForElementPresent("css=div#tagtree");
118 //add Tagset to contact
119 $this->click("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input");
120 $this->keyDown("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input", " ");
121 $this->type("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input", 'tagset1');
122 $this->typeKeys("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input", 'tagset1');
124 // ...waiting for drop down with results to show up...
125 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
127 // ...need to use mouseDownAt on first result (which is a li element), click does not work
128 $this->clickAt("xpath=//div[@class='select2-result-label']");
130 $this->waitForElementPresent("//div[@id='Tag']/div[2]/div/div/ul/li/div[text()='tagset1']");
131 $this->click("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input");
132 $this->keyDown("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input", " ");
133 $this->type("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input", 'tagset2');
134 $this->typeKeys("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input", 'tagset2');
136 // ...waiting for drop down with results to show up...
137 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
139 // ...need to use mouseDownAt on first result (which is a li element), click does not work
140 $this->clickAt("xpath=//div[@class='select2-result-label']");
143 // Type search name in autocomplete.
144 $this->click("css=input#sort_name_navigation");
145 $this->type("css=input#sort_name_navigation", $firstName);
146 $this->typeKeys("css=input#sort_name_navigation", $firstName);
148 // Wait for result list.
149 $this->waitForElementPresent("css=ul.ui-autocomplete li");
151 // Visit contact summary page.
152 $this->click("css=ul.ui-autocomplete li");
153 $this->waitForPageToLoad($this->getTimeoutMsec());
154 $this->waitForText('tags', "tagset1, tagset2");