add a few remaining missing comment blocks (autogenerated)
[civicrm-core.git] / tests / phpunit / WebTest / Contact / DeceasedContactsAdvancedSearchTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06a1bc01 4 | CiviCRM version 4.5 |
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
TO
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class WebTest_Contact_DeceasedContactsAdvancedSearchTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testDeceasedContactsAdvanceSearch() {
6a488035
TO
35 $this->webtestLogin();
36 $this->waitForPageToLoad($this->getTimeoutMsec());
37
38 // Create a group
39 $groupName = $this->WebtestAddGroup();
40
41 // Add contacts from the quick add block
42 $lastName = substr(sha1(rand()), 0, 7);
43 $names = array(
44 'firstName1' => FALSE,
45 'firstName2' => FALSE,
46 'firstName3' => FALSE,
47 'firstName4' => TRUE,
48 'firstName5' => TRUE,
49 );
50
51 foreach ($names as $key => $value) {
52 $$key = substr(sha1(rand()), 0, 7);
53 $this->_testAddContact($$key, $lastName, "{$$key}.{$lastName}@example.com", $groupName, $value);
54 }
55
56 // Advanced Search
d8bd5fb9 57 $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
6a488035
TO
58
59 // Select the group and check deceased contacts
b5e4fcd9 60 $this->select('group', "label={$groupName}");
6a488035
TO
61 $this->click('demographics');
62 $this->waitForElementPresent('CIVICRM_QFID_1_is_deceased');
63 $this->click('CIVICRM_QFID_1_is_deceased');
225a8648 64 $this->clickLink('_qf_Advanced_refresh', 'Go');
d8bd5fb9 65 $this->assertElementContainsText('search-status', '2 Contacts');
6a488035
TO
66 $this->click("toggleSelect");
67 $this->waitForTextPresent('2 Selected records only');
76e86fd8 68
6a488035 69 $this->select('task', 'label=Remove Contacts from Group');
b5e4fcd9 70 $this->click("Go");
6a488035 71 $this->waitForElementPresent('_qf_RemoveFromGroup_back-bottom');
d8bd5fb9 72 $this->assertElementContainsText('crm-container', 'Number of selected contacts: 2');
6a488035
TO
73 $this->select('group_id', "label={$groupName}");
74 $this->click('_qf_RemoveFromGroup_next-bottom');
75 $this->waitForPageToLoad($this->getTimeoutMsec());
6c5f7368 76 $this->waitForText('crm-notification-container', "2 contacts removed from '{$groupName}'");
6a488035
TO
77
78 // Search for the contacts who are not deceased
d8bd5fb9 79 $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
b5e4fcd9 80 $this->select('group', "label={$groupName}");
6a488035
TO
81 $this->click('_qf_Advanced_refresh');
82
83 // Check if non-deceased contacts are still present
84 $this->waitForElementPresent('Go');
d8bd5fb9 85 $this->assertElementContainsText('search-status', '3 Contacts');
6a488035
TO
86 }
87
4cbe18b8
EM
88 /**
89 * @param $firstName
90 * @param $lastName
91 * @param $email
92 * @param $groupName
93 * @param bool $deceased
94 */
6a488035
TO
95 function _testAddContact($firstName, $lastName, $email, $groupName, $deceased = FALSE) {
96 $this->webtestAddContact($firstName, $lastName, $email);
97 if ($deceased) {
98 $this->click('link=Edit');
99 $this->waitForElementPresent('_qf_Contact_cancel-bottom');
100
101 // Click on the Demographics tab
102 $this->click('demographics');
103 $this->waitForElementPresent('is_deceased');
104 $this->click('is_deceased');
105
106 // Click on Save
107 $this->click('_qf_Contact_upload_view-bottom');
108 $this->waitForPageToLoad($this->getTimeoutMsec());
109 }
110
111 // Add contact to group
112 $this->click('css=#tab_group a');
113 $this->waitForElementPresent('_qf_GroupContact_next');
114 $this->select('group_id', "{$groupName}");
115 $this->click('_qf_GroupContact_next');
6a488035
TO
116 }
117}
118