3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
30 * Class WebTest_Contact_AdvancedSearchedRelatedContactTest
32 class WebTest_Contact_AdvancedSearchedRelatedContactTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 public function testSearchRelatedContact() {
39 // Log in using webtestLogin() method
40 $this->webtestLogin();
42 // Use default payment processor
43 $processorName = 'Test Processor';
44 $paymentProcessorId = $this->webtestAddPaymentProcessor($processorName);
46 $this->openCiviPage('event/add', 'reset=1&action=add');
48 $eventTitle = 'My Conference - ' . substr(sha1(rand()), 0, 7);
49 $eventDescription = "Here is a description for this conference.";
50 $this->_testAddEventInfo($eventTitle, $eventDescription);
52 $streetAddress = "100 Main Street";
53 $this->_testAddLocation($streetAddress);
55 $this->_testAddFees(FALSE, FALSE, $processorName);
56 $this->openCiviPage('event/manage', 'reset=1');
57 $this->type('title', $eventTitle);
58 $this->click('_qf_SearchEvent_refresh');
59 $this->waitForPageToLoad($this->getTimeoutMsec());
60 $Id = explode('-', $this->getAttribute("xpath=//div[@id='event_status_id']/div[2]/table/tbody/tr@id"));
64 'label_a_b' => 'Owner of ' . rand(),
65 'label_b_a' => 'Belongs to ' . rand(),
66 'contact_type_a' => 'Individual',
67 'contact_type_b' => 'Individual',
68 'description' => 'The company belongs to this individual',
71 $this->webtestAddRelationshipType($params);
72 $relType = $params['label_b_a'];
74 $firstName = substr(sha1(rand()), 0, 7);
75 $this->webtestAddContact($firstName, "Anderson", "$firstName@anderson.name");
76 $sortName = "Anderson, $firstName";
77 $displayName = "$firstName Anderson";
79 //create a New Individual
80 $firstName1 = substr(sha1(rand()), 0, 7);
81 $this->webtestAddContact($firstName1, "Andy", "$firstName1@andy.name");
82 $sortName1 = "Andy, $firstName1";
83 $displayName1 = "$firstName1 Andy";
84 $this->_testAddRelationship($sortName1, $sortName, $relType);
86 $firstName2 = substr(sha1(rand()), 0, 7);
87 $this->webtestAddContact($firstName2, "David", "$firstName2@andy.name");
88 $sortName2 = "David, $firstName2";
89 $displayName2 = "$firstName2 David";
90 $this->_testAddRelationship($sortName2, $sortName, $relType);
92 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
93 $this->type("sort_name", $sortName);
94 $this->select("contact_type", "value=Individual");
95 $this->clickLink("_qf_Basic_refresh", "//table[@class='selector row-highlight']/tbody//tr/td[11]/span/a[text()='View']", FALSE);
97 // click through to the Relationship view screen
98 $this->click("xpath=//table[@class='selector row-highlight']/tbody//tr/td[11]/span/a[text()='View']");
99 $this->waitForPageToLoad($this->getTimeoutMsec());
100 $this->click("css=li#tab_participant a");
102 // wait for add Event link
103 $this->waitForElementPresent("link=Add Event Registration");
104 $this->click("link=Add Event Registration");
105 $this->waitForText("s2id_event_id", "- select event -");
106 $this->select2("event_id", $eventTitle);
107 $this->click("_qf_Participant_upload-bottom");
108 $this->waitForElementPresent("link=Add Event Registration");
110 $this->openCiviPage('contact/search/advanced', 'reset=1');
112 $this->waitForElementPresent("sort_name");
113 $this->type("sort_name", $sortName);
114 $this->click('_qf_Advanced_refresh');
115 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
117 $this->waitForElementPresent('search-status');
118 $this->assertElementContainsText('search-status', '1 Contact');
120 $this->click('css=div.crm-advanced_search_form-accordion div.crm-accordion-header');
121 $this->waitForElementPresent("component_mode");
122 $this->select("component_mode", "label=Related Contacts");
123 $this->waitForElementPresent("display_relationship_type");
124 $this->select("display_relationship_type", $relType);
125 $this->click('_qf_Advanced_refresh');
126 $this->waitForPageToLoad(2 * $this->getTimeoutMsec());
128 $this->waitForElementPresent('search-status');
129 $this->assertElementContainsText('search-status', '2 Contact');
131 $this->select("task", "label=Group - add contacts");
133 $this->waitForPageToLoad($this->getTimeoutMsec());
135 $this->click('CIVICRM_QFID_1_group_option');
137 $groupName = "Group " . substr(sha1(rand()), 0, 7);
138 $this->type('title', $groupName);
140 $this->click("_qf_AddToGroup_next-bottom");
141 $this->waitForPageToLoad($this->getTimeoutMsec());
143 $this->waitForText('crm-notification-container', "Added Contacts to " . $groupName);
144 $this->waitForText('crm-notification-container', '2 contacts added to group');
145 $this->_testSearchResult($relType);
150 * @param $eventDescription
152 public function _testAddEventInfo($eventTitle, $eventDescription) {
153 $this->waitForElementPresent("_qf_EventInfo_upload-bottom");
155 $this->select("event_type_id", "value=1");
157 // Attendee role s/b selected now.
158 $this->select("default_role_id", "value=1");
160 // Enter Event Title, Summary and Description
161 $this->type("title", $eventTitle);
162 $this->type("summary", "This is a great conference. Sign up now!");
164 // Type description in ckEditor (fieldname, text to type, editor)
165 $this->fillRichTextField("description", $eventDescription, 'CKEditor');
167 // Choose Start and End dates.
168 // Using helper webtestFillDate function.
169 $this->webtestFillDateTime("start_date", "+1 week");
170 $this->webtestFillDateTime("end_date", "+1 week 1 day 8 hours ");
172 $this->type("max_participants", "50");
173 $this->click("is_map");
174 $this->click("_qf_EventInfo_upload-bottom");
178 * @param $streetAddress
180 public function _testAddLocation($streetAddress) {
181 // Wait for Location tab form to load
182 $this->waitForPageToLoad($this->getTimeoutMsec());
183 $this->waitForElementPresent("_qf_Location_upload-bottom");
185 // Fill in address fields
186 $streetAddress = "100 Main Street";
187 $this->type("address_1_street_address", $streetAddress);
188 $this->type("address_1_city", "San Francisco");
189 $this->type("address_1_postal_code", "94117");
190 $this->select('address_1_country_id', 'UNITED STATES');
191 $this->select("address_1_state_province_id", "value=1004");
192 $this->type("email_1_email", "info@civicrm.org");
194 $this->click("_qf_Location_upload-bottom");
196 // Wait for "saved" status msg
197 $this->waitForElementPresent("_qf_Location_upload-bottom");
198 $this->waitForText('crm-notification-container', "'Event Location' information has been saved.");
202 * @param bool $discount
203 * @param bool $priceSet
204 * @param int|array $processorIDs
206 public function _testAddFees($discount = FALSE, $priceSet = FALSE, $processorIDs) {
208 $this->click("link=Fees");
209 $this->waitForElementPresent("_qf_Fee_upload-bottom");
210 $this->click("CIVICRM_QFID_1_is_monetary");
211 $this->select2('payment_processor', $processorIDs, TRUE);
212 $this->select("financial_type_id", "value=4");
217 $this->type("label_1", "Member");
218 $this->type("value_1", "250.00");
219 $this->type("label_2", "Non-member");
220 $this->type("value_2", "325.00");
222 $this->click("xpath=//table[@id='map-field-table']/tbody/tr[2]/td[3]/input");
226 // enter early bird discounts TBD
229 $this->click("_qf_Fee_upload-bottom");
231 // Wait for "saved" status msg
232 $this->waitForElementPresent("_qf_Fee_upload-bottom");
233 $this->waitForTextPresent("'Fees' information has been saved.");
237 * @param string $ContactName
238 * @param string $relatedName
241 public function _testAddRelationship($ContactName, $relatedName, $relType) {
243 $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh');
244 $this->type("sort_name", $ContactName);
245 $this->select("contact_type", "value=Individual");
246 $this->clickLink("_qf_Basic_refresh", "//div[@class='crm-search-results']/table[@class='selector row-highlight']/tbody/tr/", FALSE);
248 // click through to the Contribution view screen
249 $this->click("xpath=//div[@class='crm-search-results']/table[@class='selector row-highlight']/tbody/tr/td[11]//span/a[text()='View']");
250 $this->waitForPageToLoad($this->getTimeoutMsec());
252 $this->click("css=li#tab_rel a");
254 // wait for add Relationship link
255 $this->waitForElementPresent('link=Add Relationship');
256 $this->click('link=Add Relationship');
258 //choose the created relationship type
259 $this->waitForElementPresent("relationship_type_id");
260 $this->select('relationship_type_id', "label={$relType}");
262 //fill in the individual
263 $this->waitForElementPresent("related_contact_id");
264 $this->select2('related_contact_id', $relatedName, TRUE);
266 //fill in the relationship start date
267 $this->webtestFillDate('start_date', '-2 year');
268 $this->webtestFillDate('end_date', '+1 year');
270 $description = "Well here is some description !!!!";
271 $this->type("description", $description);
273 //save the relationship
274 //$this->click("_qf_Relationship_upload");
275 $this->click('_qf_Relationship_upload-bottom');
276 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']");
278 //check the status message
279 $this->waitForText('crm-notification-container', "Relationship created.");
280 $this->waitForElementPresent("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody//tr/td[9]/span/a[text()='View']");
281 $this->click("xpath=//div[@class='dataTables_wrapper no-footer']//table/tbody//tr/td[9]/span/a[text()='View']");
283 $this->waitForElementPresent("xpath=//table[@class='crm-info-panel']");
284 $this->webtestVerifyTabularData(
286 'Description' => $description,
287 'Status' => 'Enabled',
290 $this->assertElementContainsText("xpath=//table[@class='crm-info-panel']", $relType);
296 public function _testSearchResult($relType) {
298 //search related contact using Advanced Search
299 $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
300 $this->select("component_mode", "label=Related Contacts");
301 $this->select("display_relationship_type", "label={$relType}");
302 $this->click("CiviEvent");
303 $this->waitForElementPresent("event_type_id");
304 $this->select2("event_type_id", "Conference");
305 $this->click("_qf_Advanced_refresh");
306 $this->waitForElementPresent("xpath=//div[@class='crm-content-block']//div[@id='search-status']");
307 $this->assertElementContainsText("xpath=//div[@class='crm-content-block']//div[@id='search-status']/table/tbody/tr[1]/td[1]", "2 Contacts");
310 public function testAdvanceSearchForLog() {
311 $this->webtestLogin();
313 $Pdate = date('F jS, Y h:i:s A', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')));
314 $Ndate = date('F jS, Y h:i:s A', mktime(0, 0, 0, date('m'), date('d') +
1, date('Y')));
316 //create a contact and return the contact id
317 $firstNameSoft = "John_" . substr(sha1(rand()), 0, 5);
318 $lastNameSoft = "Doe_" . substr(sha1(rand()), 0, 5);
319 $this->webtestAddContact($firstNameSoft, $lastNameSoft);
320 $cid = $this->urlArg('cid');
322 //advance search for created contacts
323 $this->openCiviPage('contact/search/advanced', 'reset=1', '_qf_Advanced_refresh');
324 $this->type('sort_name', $lastNameSoft . ', ' . $firstNameSoft);
325 $this->click('changeLog');
326 $this->waitForElementPresent("log_date_low");
327 $this->select("log_date_relative", "value=0");
328 $this->webtestFillDate('log_date_low', "-1 day");
329 $this->webtestFillDate('log_date_high', "+1 day");
330 $this->click('_qf_Advanced_refresh');
331 $this->waitForPageToLoad($this->getTimeoutMsec());
332 $this->assertTrue(TRUE, 'greater than or equal to "{$Pdate}" AND less than or equal to "{$Ndate}"');
333 $value = "$lastNameSoft, $firstNameSoft";
334 $this->waitForElementPresent("xpath= id('rowid{$cid}')/td[3]/a");
335 $this->verifyText("xpath= id('rowid{$cid}')/td[3]/a", preg_quote($value));