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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contact_ContactTagTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testTagAContact() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
39 $this->open($this->sboxPath
);
41 // Logging in. Remember to wait for page to load. In most cases,
42 // you can rely on 30000 as the value that allows your test to pass, however,
43 // sometimes your test might fail because of this. In such cases, it's better to pick one element
44 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
45 // page contents loaded and you can continue your test execution.
46 $this->webtestLogin();
48 // Go directly to the URL of the screen that you will be testing (New Tag).
49 $this->open($this->sboxPath
. "civicrm/admin/tag?action=add&reset=1");
51 // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit
52 // button at the end of this page to show up, to make sure it's fully loaded.
53 $this->waitForElementPresent("_qf_Tag_next");
56 $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
59 $this->type("name", $tagName);
62 $this->type("description", "Adding new tag.");
64 // select used for contact
65 $this->select("used_for", "value=civicrm_contact");
68 $this->click("is_reserved");
71 $this->click("_qf_Tag_next");
72 $this->waitForPageToLoad($this->getTimeoutMsec());
74 // Is status message correct?
75 $this->assertTrue($this->isTextPresent("The tag '$tagName' has been saved."));
78 // We're using Quick Add block on the main page for this.
79 $firstName = substr(sha1(rand()), 0, 7);
80 $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
83 $this->click("css=li#tab_tag a");
84 $this->waitForElementPresent("css=div#tagtree");
86 // check tag we have created
87 $this->click("xpath=//ul/li/label[text()=\"$tagName\"]");
88 $this->waitForElementPresent("css=.success");
90 // Is status message correct?
91 $this->assertTrue($this->isTextPresent("Saved"));
94 function testTagSetContact() {
95 // This is the path where our testing install resides.
96 // The rest of URL is defined in CiviSeleniumTestCase base class, in
98 $this->open($this->sboxPath
);
100 // Logging in. Remember to wait for page to load. In most cases,
101 // you can rely on 30000 as the value that allows your test to pass, however,
102 // sometimes your test might fail because of this. In such cases, it's better to pick one element
103 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
104 // page contents loaded and you can continue your test execution.
105 $this->webtestLogin();
107 // Go directly to the URL of the screen that you will be testing (New Tag).
108 $this->open($this->sboxPath
. "civicrm/admin/tag?action=add&reset=1&tagset=1");
110 // take a tagset name
111 $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
114 $this->type("name", $tagSetName);
117 $this->type("description", "Adding new tag set.");
119 // select used for contact
120 $this->select("used_for", "value=civicrm_contact");
123 $this->click("is_reserved");
126 $this->click("_qf_Tag_next");
127 $this->waitForPageToLoad($this->getTimeoutMsec());
129 // Is status message correct?
130 $this->assertTrue($this->isTextPresent("The tag '$tagSetName' has been saved."));
133 // We're using Quick Add block on the main page for this.
134 $firstName = substr(sha1(rand()), 0, 7);
135 $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
138 $this->click("css=li#tab_tag a");
139 $this->waitForElementPresent("css=div#tagtree");
141 //add Tagset to contact
142 $this->click("//div[@id='Tag']/div[3]/div[1]/ul/li[1]/input");
143 $this->type("//div[@id='Tag']/div[3]/div[1]/ul/li[1]/input", 'tagset1');
144 $this->typeKeys("//div[@id='Tag']/div[3]/div[1]/ul/li[1]/input", 'tagset1');
146 // ...waiting for drop down with results to show up...
147 $this->waitForElementPresent("css=div.token-input-dropdown-facebook");
148 $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook");
150 // ...need to use mouseDownAt on first result (which is a li element), click does not work
151 $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook");
153 $this->waitForElementPresent("//div[@id='Tag']/div[3]/div[1]/ul/li[1]/span");
154 $this->click("//div[@id='Tag']/div[3]/div[1]/ul/li[2]/input");
155 $this->type("//div[@id='Tag']/div[3]/div[1]/ul/li[2]/input", 'tagset2');
156 $this->typeKeys("//div[@id='Tag']/div[3]/div[1]/ul/li[2]/input", 'tagset2');
158 // ...waiting for drop down with results to show up...
159 $this->waitForElementPresent("css=div.token-input-dropdown-facebook");
160 $this->waitForElementPresent("css=li.token-input-dropdown-item2-facebook");
162 // ...need to use mouseDownAt on first result (which is a li element), click does not work
163 $this->mouseDownAt("css=li.token-input-dropdown-item2-facebook");
165 $this->click("//div[@id='Tag']/div[3]/div[1]/ul/li");
167 // Type search name in autocomplete.
168 $this->click("css=input#sort_name_navigation");
169 $this->type("css=input#sort_name_navigation", $firstName);
170 $this->typeKeys("css=input#sort_name_navigation", $firstName);
172 // Wait for result list.
173 $this->waitForElementPresent("css=div.ac_results-inner li");
175 // Visit contact summary page.
176 $this->click("css=div.ac_results-inner li");
177 $this->waitForPageToLoad($this->getTimeoutMsec());
178 $this->assertTrue($this->isTextPresent("tagset1, tagset2"));