Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
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_TagAddTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contact_TagAddTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testAddTag() { | |
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? | |
63 | $this->assertTrue($this->isTextPresent("The tag '$tagName' has been saved.")); | |
64 | ||
65 | // sort by ID desc | |
66 | $this->click("xpath=//table//tr/th[text()=\"ID\"]"); | |
67 | $this->waitForElementPresent("css=table.display tbody tr td"); | |
68 | ||
69 | // verify text | |
70 | $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']"); | |
71 | $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[2][text()='Adding new tag. ']"); | |
72 | $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[4][text()= 'Contacts']"); | |
73 | $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[7]/span/a[text()= 'Edit']"); | |
74 | } | |
75 | ||
76 | function testAddTagSet() { | |
6a488035 TO |
77 | $this->webtestLogin(); |
78 | ||
071a6d2e | 79 | $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1"); |
6a488035 TO |
80 | |
81 | // take a tagset name | |
82 | $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7); | |
83 | ||
84 | // fill tagset name | |
85 | $this->type("name", $tagSetName); | |
86 | ||
87 | // fill description | |
88 | $this->type("description", "Adding new tag set."); | |
89 | ||
90 | // select used for contact | |
91 | $this->select("used_for", "value=civicrm_contact"); | |
92 | ||
93 | // check reserved | |
94 | $this->click("is_reserved"); | |
95 | ||
96 | // Clicking save. | |
97 | $this->click("_qf_Tag_next"); | |
98 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
99 | ||
100 | // Is status message correct? | |
101 | $this->assertTrue($this->isTextPresent("The tag '$tagSetName' has been saved.")); | |
102 | ||
103 | // sort by ID desc | |
104 | $this->click("xpath=//table//tr/th[text()=\"ID\"]"); | |
105 | $this->waitForElementPresent("css=table.display tbody tr td"); | |
106 | ||
107 | // verify text | |
108 | $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']"); | |
109 | $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[2][text()='Adding new tag set. ']"); | |
110 | $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[4][text()= 'Contacts']"); | |
111 | $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']"); | |
112 | } | |
113 | } | |
114 |