Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
25 | */ | |
26 | ||
6a488035 TO |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Contact_ContactTagTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testTagAContact() { | |
6a488035 TO |
35 | $this->webtestLogin(); |
36 | ||
42daf119 | 37 | $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next"); |
6a488035 TO |
38 | |
39 | // take a tag name | |
40 | $tagName = 'tag_' . substr(sha1(rand()), 0, 7); | |
41 | ||
42 | // fill tag name | |
43 | $this->type("name", $tagName); | |
44 | ||
45 | // fill description | |
46 | $this->type("description", "Adding new tag."); | |
47 | ||
48 | // select used for contact | |
49 | $this->select("used_for", "value=civicrm_contact"); | |
50 | ||
51 | // check reserved | |
52 | $this->click("is_reserved"); | |
53 | ||
54 | // Clicking save. | |
55 | $this->click("_qf_Tag_next"); | |
56 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
57 | ||
58 | // Is status message correct? | |
59 | $this->assertTrue($this->isTextPresent("The tag '$tagName' has been saved.")); | |
60 | ||
61 | // Adding contact | |
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"); | |
65 | ||
66 | // visit tag tab | |
67 | $this->click("css=li#tab_tag a"); | |
68 | $this->waitForElementPresent("css=div#tagtree"); | |
69 | ||
70 | // check tag we have created | |
71 | $this->click("xpath=//ul/li/label[text()=\"$tagName\"]"); | |
72 | $this->waitForElementPresent("css=.success"); | |
73 | ||
74 | // Is status message correct? | |
75 | $this->assertTrue($this->isTextPresent("Saved")); | |
76 | } | |
77 | ||
78 | function testTagSetContact() { | |
6a488035 TO |
79 | $this->webtestLogin(); |
80 | ||
071a6d2e | 81 | $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1"); |
6a488035 TO |
82 | |
83 | // take a tagset name | |
84 | $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7); | |
85 | ||
86 | // fill tagset name | |
87 | $this->type("name", $tagSetName); | |
88 | ||
89 | // fill description | |
90 | $this->type("description", "Adding new tag set."); | |
91 | ||
92 | // select used for contact | |
93 | $this->select("used_for", "value=civicrm_contact"); | |
94 | ||
95 | // check reserved | |
96 | $this->click("is_reserved"); | |
97 | ||
98 | // Clicking save. | |
99 | $this->click("_qf_Tag_next"); | |
100 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
101 | ||
102 | // Is status message correct? | |
103 | $this->assertTrue($this->isTextPresent("The tag '$tagSetName' has been saved.")); | |
104 | ||
105 | // Adding contact | |
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"); | |
109 | ||
110 | // visit tag tab | |
111 | $this->click("css=li#tab_tag a"); | |
112 | $this->waitForElementPresent("css=div#tagtree"); | |
113 | ||
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'); | |
118 | ||
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"); | |
122 | ||
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"); | |
125 | ||
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'); | |
130 | ||
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"); | |
134 | ||
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"); | |
137 | ||
138 | $this->click("//div[@id='Tag']/div[3]/div[1]/ul/li"); | |
139 | ||
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); | |
144 | ||
145 | // Wait for result list. | |
146 | $this->waitForElementPresent("css=div.ac_results-inner li"); | |
147 | ||
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")); | |
152 | } | |
153 | } | |
154 |