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_ContactTagTest
32 class WebTest_Contact_ContactTagTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public 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/span/label[text()=\"$tagName\"]");
76 $this->checkCRMStatus();
79 public function testTagSetContact() {
80 $this->webtestLogin();
82 $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1");
85 $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
88 $this->type("name", $tagSetName);
91 $this->type("description", "Adding new tag set.");
93 // select used for contact
94 $this->select("used_for", "value=civicrm_contact");
97 $this->click("is_reserved");
100 $this->click("_qf_Tag_next");
101 $this->waitForPageToLoad($this->getTimeoutMsec());
103 // Is status message correct?
104 $this->waitForText('crm-notification-container', "The tag '$tagSetName' has been saved.");
107 // We're using Quick Add block on the main page for this.
108 $firstName = substr(sha1(rand()), 0, 7);
109 $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
112 $this->click("css=li#tab_tag a");
113 $this->waitForElementPresent("css=div#tagtree");
115 //add Tagset to contact
116 $this->click("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input");
117 $this->keyDown("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input", " ");
118 $this->type("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input", 'tagset1');
119 $this->typeKeys("xpath=//div[@id='Tag']/div[2]/div/div/ul/li/input", 'tagset1');
121 // ...waiting for drop down with results to show up...
122 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
124 // ...need to use mouseDownAt on first result (which is a li element), click does not work
125 $this->clickAt("xpath=//div[@class='select2-result-label']");
127 $this->waitForElementPresent("//div[@id='Tag']/div[2]/div/div/ul/li/div[text()='tagset1']");
128 $this->click("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input");
129 $this->keyDown("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input", " ");
130 $this->type("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input", 'tagset2');
131 $this->typeKeys("xpath=//div[@id='Tag']/div[2]/div/div/ul/li[2]/input", 'tagset2');
133 // ...waiting for drop down with results to show up...
134 $this->waitForElementPresent("xpath=//div[@class='select2-result-label']");
136 // ...need to use mouseDownAt on first result (which is a li element), click does not work
137 $this->clickAt("xpath=//div[@class='select2-result-label']");
139 // Type search name in autocomplete.
140 $this->click("css=input#sort_name_navigation");
141 $this->type("css=input#sort_name_navigation", $firstName);
142 $this->typeKeys("css=input#sort_name_navigation", $firstName);
144 // Wait for result list.
145 $this->waitForElementPresent("css=ul.ui-autocomplete li");
147 // Visit contact summary page.
148 $this->click("css=ul.ui-autocomplete li");
149 $this->waitForPageToLoad($this->getTimeoutMsec());
150 $this->waitForText('tags', "tagset1, tagset2");