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_TaskActionAddToGroupTest
extends CiviSeleniumTestCase
{
31 protected function setUp() {
35 function testAddContactsToGroup() {
37 $this->webtestLogin();
38 $newGroupName = 'Group_' . substr(sha1(rand()), 0, 7);
39 $this->WebtestAddGroup($newGroupName);
41 // Create two new contacts with a common random string in email address
42 $emailString = substr(sha1(rand()), 0, 7) . '@example.com_';
44 for ($i = 0; $i < 2; $i++
) {
46 $this->webtestAddContact();
48 // get cid of new contact
49 $queryParams = $this->parseURL();
50 $cids[] = $queryParams['queryString']['cid'];
52 // update email of new contact
53 $this->click("//ul[@id='actions']/li/a/span[text()='Edit']");
54 $this->waitForPageToLoad($this->getTimeoutMsec());
55 $this->type("email_1_email", $emailString . $i . 'webtest');
56 $this->click("_qf_Contact_upload_view");
57 $this->waitForPageToLoad($this->getTimeoutMsec());
60 // goto advanced search
61 $this->openCiviPage("contact/search/advanced", "reset=1", "email");
63 $this->type("email", $emailString);
64 $this->click("_qf_Advanced_refresh");
65 $this->waitForPageToLoad($this->getTimeoutMsec());
67 // Verify exactly two contacts found
68 $this->assertTrue($this->isTextPresent("2 Contacts"), 'Looking for 2 results with email like ' . $emailString);
70 // Click "check all" box and act on "Add to group" action
71 $this->click('toggleSelect');
72 $this->select("task", "label=Add Contacts to Group");
75 $this->waitForPageToLoad($this->getTimeoutMsec());
77 // Select the new group and click to add
78 $this->click("group_id");
79 $this->select("group_id", "label=" . $newGroupName);
80 $this->click("_qf_AddToGroup_next-bottom");
81 $this->waitForPageToLoad($this->getTimeoutMsec());
83 // Check status messages are as expected
84 $this->assertElementContainsText('crm-notification-container', "Added Contacts to {$newGroupName}");
85 $this->assertElementContainsText('crm-notification-container', "2 contacts added to group");
87 // Search by group membership in newly created group
88 $this->openCiviPage('contact/search/advanced', 'reset=1');
89 $this->select("crmasmSelect1", "label=" . $newGroupName);
90 $this->click("_qf_Advanced_refresh");
91 $this->waitForPageToLoad($this->getTimeoutMsec());
93 // Verify those two contacts (and only those two) are in the group
94 if (!$this->isTextPresent("2 Contacts")) {
95 die("nothing found for group $newGroupName");
98 $this->assertTrue($this->isTextPresent("2 Contacts"), 'Looking for 2 results belonging to group: ' . $newGroupName);
99 foreach ($cids as $cid) {
100 $this->assertTrue($this->isElementPresent('rowid' . $cid));
105 function testMultiplePageContactSearchAddContactsToGroup() {
106 $this->webtestLogin();
107 $newGroupName = 'Group_' . substr(sha1(rand()), 0, 7);
108 $this->WebtestAddGroup($newGroupName);
110 $this->openCiviPage('contact/search', 'reset=1');
111 $this->click("_qf_Basic_refresh");
112 $this->waitForPageToLoad($this->getTimeoutMsec());
114 $this->click("xpath=//div[@class='form-item float-right']/a[text()='25']");
115 $this->waitForPageToLoad($this->getTimeoutMsec());
116 $this->click("toggleSelect");
117 $this->click("xpath=//div[@class='crm-content-block']/div/div[2]/div/span[2]/a");
118 $this->waitForPageToLoad($this->getTimeoutMsec());
119 $this->click("toggleSelect");
120 $this->select("task", "label=Add Contacts to Group");
122 $this->waitForPageToLoad($this->getTimeoutMsec());
124 // Select the new group and click to add
125 $this->click("group_id");
126 $this->select("group_id", "label=" . $newGroupName);
127 $this->click("_qf_AddToGroup_next-bottom");
128 $this->waitForPageToLoad($this->getTimeoutMsec());
130 // Check status messages are as expected
131 $this->assertElementContainsText('crm-notification-container', "Added Contacts to {$newGroupName}");
132 $this->assertElementContainsText('crm-notification-container', "50 contacts added to group");
134 $this->openCiviPage('contact/search/advanced', 'reset=1');
135 $this->select("crmasmSelect1", "label=" . $newGroupName);
136 $this->click("_qf_Advanced_refresh");
137 $this->waitForPageToLoad($this->getTimeoutMsec());
139 $this->assertTrue($this->isTextPresent("50 Contacts"), 'Looking for 50 results belonging to group: ' . $newGroupName);