Mass switch to openCiviPage method
[civicrm-core.git] / tests / phpunit / WebTest / Contact / TagAddTest.php
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
27
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contact_TagAddTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testAddTag() {
36 $this->webtestLogin();
37
38 $this->openCiviPage("admin/tag", "action=add&reset=1", "_qf_Tag_next");
39
40 // take a tag name
41 $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
42
43 // fill tag name
44 $this->type("name", $tagName);
45
46 // fill description
47 $this->type("description", "Adding new tag.");
48
49 // select used for contact
50 $this->select("used_for", "value=civicrm_contact");
51
52 // check reserved
53 $this->click("is_reserved");
54
55 // Clicking save.
56 $this->click("_qf_Tag_next");
57 $this->waitForPageToLoad($this->getTimeoutMsec());
58
59 // Is status message correct?
60 $this->assertTrue($this->isTextPresent("The tag '$tagName' has been saved."));
61
62 // sort by ID desc
63 $this->click("xpath=//table//tr/th[text()=\"ID\"]");
64 $this->waitForElementPresent("css=table.display tbody tr td");
65
66 // verify text
67 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']");
68 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[2][text()='Adding new tag. ']");
69 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[4][text()= 'Contacts']");
70 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[7]/span/a[text()= 'Edit']");
71 }
72
73 function testAddTagSet() {
74 $this->webtestLogin();
75
76 $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1");
77
78 // take a tagset name
79 $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
80
81 // fill tagset name
82 $this->type("name", $tagSetName);
83
84 // fill description
85 $this->type("description", "Adding new tag set.");
86
87 // select used for contact
88 $this->select("used_for", "value=civicrm_contact");
89
90 // check reserved
91 $this->click("is_reserved");
92
93 // Clicking save.
94 $this->click("_qf_Tag_next");
95 $this->waitForPageToLoad($this->getTimeoutMsec());
96
97 // Is status message correct?
98 $this->assertTrue($this->isTextPresent("The tag '$tagSetName' has been saved."));
99
100 // sort by ID desc
101 $this->click("xpath=//table//tr/th[text()=\"ID\"]");
102 $this->waitForElementPresent("css=table.display tbody tr td");
103
104 // verify text
105 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']");
106 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[2][text()='Adding new tag set. ']");
107 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[4][text()= 'Contacts']");
108 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']");
109 }
110 }
111
112