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 | |
bf333c47 | 75 | $this->click("xpath=//ul/li/span/label[text()=\"$tagName\"]"); |
5c88df60 | 76 | $this->checkCRMStatus(); |
6a488035 TO |
77 | } |
78 | ||
79 | function testTagSetContact() { | |
6a488035 TO |
80 | $this->webtestLogin(); |
81 | ||
071a6d2e | 82 | $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1"); |
6a488035 TO |
83 | |
84 | // take a tagset name | |
85 | $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7); | |
86 | ||
87 | // fill tagset name | |
88 | $this->type("name", $tagSetName); | |
89 | ||
90 | // fill description | |
91 | $this->type("description", "Adding new tag set."); | |
92 | ||
93 | // select used for contact | |
94 | $this->select("used_for", "value=civicrm_contact"); | |
95 | ||
96 | // check reserved | |
97 | $this->click("is_reserved"); | |
98 | ||
99 | // Clicking save. | |
100 | $this->click("_qf_Tag_next"); | |
101 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
102 | ||
103 | // Is status message correct? | |
2053a3e9 | 104 | $this->waitForText('crm-notification-container', "The tag '$tagSetName' has been saved."); |
6a488035 TO |
105 | |
106 | // Adding contact | |
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"); | |
110 | ||
111 | // visit tag tab | |
112 | $this->click("css=li#tab_tag a"); | |
113 | $this->waitForElementPresent("css=div#tagtree"); | |
114 | ||
115 | //add Tagset to contact | |
1d4d99e9 | 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'); | |
6a488035 TO |
120 | |
121 | // ...waiting for drop down with results to show up... | |
1d4d99e9 | 122 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
123 | |
124 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
1d4d99e9 | 125 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
126 | sleep(2); | |
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'); | |
6a488035 TO |
132 | |
133 | // ...waiting for drop down with results to show up... | |
1d4d99e9 | 134 | $this->waitForElementPresent("xpath=//div[@class='select2-result-label']"); |
6a488035 TO |
135 | |
136 | // ...need to use mouseDownAt on first result (which is a li element), click does not work | |
1d4d99e9 | 137 | $this->clickAt("xpath=//div[@class='select2-result-label']"); |
6a488035 | 138 | |
6a488035 TO |
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. | |
1d4d99e9 | 146 | $this->waitForElementPresent("css=ul.ui-autocomplete li"); |
6a488035 TO |
147 | |
148 | // Visit contact summary page. | |
1d4d99e9 | 149 | $this->click("css=ul.ui-autocomplete li"); |
6a488035 | 150 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
2053a3e9 | 151 | $this->waitForText('tags', "tagset1, tagset2"); |
6a488035 TO |
152 | } |
153 | } | |
154 |