Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contact_ContactTagTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contact_ContactTagTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testTagAContact() { | |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | ||
42daf119 | 41 | $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next"); |
6a488035 TO |
42 | |
43 | // take a tag name | |
44 | $tagName = 'tag_' . substr(sha1(rand()), 0, 7); | |
45 | ||
46 | // fill tag name | |
47 | $this->type("name", $tagName); | |
48 | ||
49 | // fill description | |
50 | $this->type("description", "Adding new tag."); | |
51 | ||
52 | // select used for contact | |
53 | $this->select("used_for", "value=civicrm_contact"); | |
54 | ||
55 | // check reserved | |
56 | $this->click("is_reserved"); | |
57 | ||
58 | // Clicking save. | |
59 | $this->click("_qf_Tag_next"); | |
60 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
61 | ||
62 | // Is status message correct? | |
2053a3e9 | 63 | $this->waitForText('crm-notification-container', "The tag '$tagName' has been saved."); |
6a488035 TO |
64 | |
65 | // Adding contact | |
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"); | |
69 | ||
70 | // visit tag tab | |
71 | $this->click("css=li#tab_tag a"); | |
72 | $this->waitForElementPresent("css=div#tagtree"); | |
73 | ||
74 | // check tag we have created | |
75 | $this->click("xpath=//ul/li/label[text()=\"$tagName\"]"); | |
76 | $this->waitForElementPresent("css=.success"); | |
77 | ||
78 | // Is status message correct? | |
2053a3e9 | 79 | $this->waitForText('crm-notification-container', "Saved"); |
6a488035 TO |
80 | } |
81 | ||
82 | function testTagSetContact() { | |
6a488035 TO |
83 | $this->webtestLogin(); |
84 | ||
071a6d2e | 85 | $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1"); |
6a488035 TO |
86 | |
87 | // take a tagset name | |
88 | $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7); | |
89 | ||
90 | // fill tagset name | |
91 | $this->type("name", $tagSetName); | |
92 | ||
93 | // fill description | |
94 | $this->type("description", "Adding new tag set."); | |
95 | ||
96 | // select used for contact | |
97 | $this->select("used_for", "value=civicrm_contact"); | |
98 | ||
99 | // check reserved | |
100 | $this->click("is_reserved"); | |
101 | ||
102 | // Clicking save. | |
103 | $this->click("_qf_Tag_next"); | |
104 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
105 | ||
106 | // Is status message correct? | |
2053a3e9 | 107 | $this->waitForText('crm-notification-container', "The tag '$tagSetName' has been saved."); |
6a488035 TO |
108 | |
109 | // Adding contact | |
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"); | |
113 | ||
114 | // visit tag tab | |
115 | $this->click("css=li#tab_tag a"); | |
116 | $this->waitForElementPresent("css=div#tagtree"); | |
117 | ||
118 | //add Tagset to contact | |
1d4d99e9 | 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'); | |
6a488035 TO |
123 | |
124 | // ...waiting for drop down with results to show up... | |
1d4d99e9 | 125 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
126 | |
127 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
1d4d99e9 | 128 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
129 | sleep(2); | |
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'); | |
6a488035 TO |
135 | |
136 | // ...waiting for drop down with results to show up... | |
1d4d99e9 | 137 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
138 | |
139 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
1d4d99e9 | 140 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
6a488035 | 141 | |
6a488035 TO |
142 | |
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); | |
147 | ||
148 | // Wait for result list. | |
1d4d99e9 | 149 | $this->waitForElementPresent("css=ul.ui-autocomplete li"); |
6a488035 TO |
150 | |
151 | // Visit contact summary page. | |
1d4d99e9 | 152 | $this->click("css=ul.ui-autocomplete li"); |
6a488035 | 153 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
2053a3e9 | 154 | $this->waitForText('tags', "tagset1, tagset2"); |
6a488035 TO |
155 | } |
156 | } | |
157 |