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