Merge remote-tracking branch 'upstream/4.3' into 4.3-4.4-2013-11-26-11-43-18
[civicrm-core.git] / tests / phpunit / WebTest / Contact / TagAddTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
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
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Contact_TagAddTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testAddTag() {
35 $this->webtestLogin();
36
37 $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next");
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 // sort by ID desc
62 $this->click("xpath=//table//tr/th[text()=\"ID\"]");
63 $this->waitForElementPresent("css=table.display tbody tr td");
64
65 // verify text
66 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']");
67 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[2][text()='Adding new tag. ']");
68 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[4][text()= 'Contacts']");
69 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[7]/span/a[text()= 'Edit']");
70 }
71
72 function testAddTagSet() {
73 $this->webtestLogin();
74
75 $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1");
76
77 // take a tagset name
78 $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
79
80 // fill tagset name
81 $this->type("name", $tagSetName);
82
83 // fill description
84 $this->type("description", "Adding new tag set.");
85
86 // select used for contact
87 $this->select("used_for", "value=civicrm_contact");
88
89 // check reserved
90 $this->click("is_reserved");
91
92 // Clicking save.
93 $this->click("_qf_Tag_next");
94 $this->waitForPageToLoad($this->getTimeoutMsec());
95
96 // Is status message correct?
97 $this->assertTrue($this->isTextPresent("The tag '$tagSetName' has been saved."));
98
99 // sort by ID desc
100 $this->click("xpath=//table//tr/th[text()=\"ID\"]");
101 $this->waitForElementPresent("css=table.display tbody tr td");
102
103 // verify text
104 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']");
105 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[2][text()='Adding new tag set. ']");
106 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[4][text()= 'Contacts']");
107 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']");
108 }
109 }
110