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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 25 | */ |
6a488035 | 26 | |
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contact_TaskActionAddToGroupTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contact_TaskActionAddToGroupTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testAddContactsToGroup() { |
6a488035 | 39 | |
69369531 | 40 | $this->webtestLogin(); |
6a488035 TO |
41 | $newGroupName = 'Group_' . substr(sha1(rand()), 0, 7); |
42 | $this->WebtestAddGroup($newGroupName); | |
43 | ||
44 | // Create two new contacts with a common random string in email address | |
bf333c47 | 45 | $emailString = substr(sha1(rand()), 0, 7) . '@example.com'; |
6a488035 TO |
46 | $cids = array(); |
47 | for ($i = 0; $i < 2; $i++) { | |
48 | // create new contact | |
49 | $this->webtestAddContact(); | |
50 | ||
51 | // get cid of new contact | |
a471a3b6 | 52 | $cids[] = $this->urlArg('cid'); |
6a488035 TO |
53 | |
54 | // update email of new contact | |
27c7ef42 | 55 | $this->waitForElementPresent("//ul[@id='actions']/li/a/span[text()='Edit']"); |
6a488035 TO |
56 | $this->click("//ul[@id='actions']/li/a/span[text()='Edit']"); |
57 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
58 | $this->type("email_1_email", $emailString . $i . 'webtest'); | |
59 | $this->click("_qf_Contact_upload_view"); | |
60 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
61 | } | |
62 | ||
63 | // goto advanced search | |
64 | $this->openCiviPage("contact/search/advanced", "reset=1", "email"); | |
65 | ||
66 | $this->type("email", $emailString); | |
67 | $this->click("_qf_Advanced_refresh"); | |
68 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
69 | ||
70 | // Verify exactly two contacts found | |
71 | $this->assertTrue($this->isTextPresent("2 Contacts"), 'Looking for 2 results with email like ' . $emailString); | |
72 | ||
73 | // Click "check all" box and act on "Add to group" action | |
74 | $this->click('toggleSelect'); | |
bf333c47 | 75 | $this->waitForText("xpath=//input[@value='ts_sel']/following-sibling::label/span", '2'); |
6a488035 | 76 | $this->select("task", "label=Add Contacts to Group"); |
6a488035 TO |
77 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
78 | ||
79 | // Select the new group and click to add | |
80 | $this->click("group_id"); | |
81 | $this->select("group_id", "label=" . $newGroupName); | |
82 | $this->click("_qf_AddToGroup_next-bottom"); | |
83 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
84 | ||
85 | // Check status messages are as expected | |
6c5f7368 CW |
86 | $this->waitForText('crm-notification-container', "Added Contacts to {$newGroupName}"); |
87 | $this->waitForText('crm-notification-container', "2 contacts added to group"); | |
6a488035 TO |
88 | |
89 | // Search by group membership in newly created group | |
90 | $this->openCiviPage('contact/search/advanced', 'reset=1'); | |
c900afb1 | 91 | $this->select("group", "label=" . $newGroupName); |
6a488035 TO |
92 | $this->click("_qf_Advanced_refresh"); |
93 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
94 | ||
95 | // Verify those two contacts (and only those two) are in the group | |
96 | if (!$this->isTextPresent("2 Contacts")) { | |
97 | die("nothing found for group $newGroupName"); | |
98 | } | |
99 | ||
100 | $this->assertTrue($this->isTextPresent("2 Contacts"), 'Looking for 2 results belonging to group: ' . $newGroupName); | |
101 | foreach ($cids as $cid) { | |
102 | $this->assertTrue($this->isElementPresent('rowid' . $cid)); | |
103 | } | |
104 | ||
105 | } | |
106 | ||
00be9182 | 107 | public function testMultiplePageContactSearchAddContactsToGroup() { |
69369531 | 108 | $this->webtestLogin(); |
6a488035 TO |
109 | $newGroupName = 'Group_' . substr(sha1(rand()), 0, 7); |
110 | $this->WebtestAddGroup($newGroupName); | |
111 | ||
112 | $this->openCiviPage('contact/search', 'reset=1'); | |
beea38fc | 113 | $this->clickLink("_qf_Basic_refresh"); |
6a488035 | 114 | |
bf333c47 | 115 | $this->type("xpath=//*[@id='CRM_Contact_Form_Search_Basic-rows-per-page-select']", '25'); |
c900afb1 | 116 | $this->waitForElementPresent("toggleSelect"); |
6a488035 TO |
117 | $this->click("toggleSelect"); |
118 | $this->click("xpath=//div[@class='crm-content-block']/div/div[2]/div/span[2]/a"); | |
c900afb1 | 119 | $this->waitForText("xpath=//div[@class='crm-content-block']/div/div[2]/div/span[2]/a", "First"); |
6a488035 | 120 | $this->click("toggleSelect"); |
bf333c47 | 121 | $this->waitForText("xpath=//input[@value='ts_sel']/following-sibling::label/span", '50'); |
6a488035 | 122 | $this->select("task", "label=Add Contacts to Group"); |
6a488035 TO |
123 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
124 | ||
6c6e6187 | 125 | // Select the new group and click to add |
6a488035 TO |
126 | $this->click("group_id"); |
127 | $this->select("group_id", "label=" . $newGroupName); | |
128 | $this->click("_qf_AddToGroup_next-bottom"); | |
129 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
130 | ||
131 | // Check status messages are as expected | |
6c5f7368 CW |
132 | $this->waitForText('crm-notification-container', "Added Contacts to {$newGroupName}"); |
133 | $this->waitForText('crm-notification-container', "50 contacts added to group"); | |
6a488035 TO |
134 | |
135 | $this->openCiviPage('contact/search/advanced', 'reset=1'); | |
c900afb1 | 136 | $this->select("group", "label=" . $newGroupName); |
6a488035 TO |
137 | $this->click("_qf_Advanced_refresh"); |
138 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
139 | ||
140 | $this->assertTrue($this->isTextPresent("50 Contacts"), 'Looking for 50 results belonging to group: ' . $newGroupName); | |
141 | } | |
96025800 | 142 | |
6a488035 | 143 | } |