3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviSeleniumTestCase.php';
29 class WebTest_Contact_TagAddTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testAddTag() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
39 $this->open($this->sboxPath
);
41 // Logging in. Remember to wait for page to load. In most cases,
42 // you can rely on 30000 as the value that allows your test to pass, however,
43 // sometimes your test might fail because of this. In such cases, it's better to pick one element
44 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
45 // page contents loaded and you can continue your test execution.
46 $this->webtestLogin();
48 // Go directly to the URL of the screen that you will be testing (New Tag).
49 $this->open($this->sboxPath
. "civicrm/admin/tag?action=add&reset=1");
51 // As mentioned before, waitForPageToLoad is not always reliable. Below, we're waiting for the submit
52 // button at the end of this page to show up, to make sure it's fully loaded.
53 $this->waitForElementPresent("_qf_Tag_next");
56 $tagName = 'tag_' . substr(sha1(rand()), 0, 7);
59 $this->type("name", $tagName);
62 $this->type("description", "Adding new tag.");
64 // select used for contact
65 $this->select("used_for", "value=civicrm_contact");
68 $this->click("is_reserved");
71 $this->click("_qf_Tag_next");
72 $this->waitForPageToLoad($this->getTimeoutMsec());
74 // Is status message correct?
75 $this->assertTrue($this->isTextPresent("The tag '$tagName' has been saved."));
78 $this->click("xpath=//table//tr/th[text()=\"ID\"]");
79 $this->waitForElementPresent("css=table.display tbody tr td");
82 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']");
83 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[2][text()='Adding new tag. ']");
84 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[4][text()= 'Contacts']");
85 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagName']/following-sibling::td[7]/span/a[text()= 'Edit']");
88 function testAddTagSet() {
89 $this->open($this->sboxPath
);
90 $this->webtestLogin();
92 // Go directly to the URL of the screen that you will be testing (New Tag).
93 $this->open($this->sboxPath
. "civicrm/admin/tag?action=add&reset=1&tagset=1");
96 $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7);
99 $this->type("name", $tagSetName);
102 $this->type("description", "Adding new tag set.");
104 // select used for contact
105 $this->select("used_for", "value=civicrm_contact");
108 $this->click("is_reserved");
111 $this->click("_qf_Tag_next");
112 $this->waitForPageToLoad($this->getTimeoutMsec());
114 // Is status message correct?
115 $this->assertTrue($this->isTextPresent("The tag '$tagSetName' has been saved."));
118 $this->click("xpath=//table//tr/th[text()=\"ID\"]");
119 $this->waitForElementPresent("css=table.display tbody tr td");
122 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']");
123 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[2][text()='Adding new tag set. ']");
124 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[4][text()= 'Contacts']");
125 $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '$tagSetName']/following-sibling::td[7]/span/a[text()= 'Edit']");