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 +--------------------------------------------------------------------+
27 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Profile_SearchTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testSearchProfile() {
35 $this->webtestLogin();
38 $this->openCiviPage('admin/uf/group', 'reset=1');
40 $this->click('newCiviCRMProfile-bottom');
42 $this->waitForElementPresent('_qf_Group_next-bottom');
45 $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7);
46 $this->type('title', $profileTitle);
49 $this->click('_qf_Group_next-bottom');
50 $this->waitForPageToLoad($this->getTimeoutMsec());
52 //check for profile create
53 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
55 // Get profile id (gid) from URL
56 $profileId = $this->urlArg('gid');
58 // Add Last Name field.
59 $this->click('field_name[0]');
60 $this->select('field_name[0]', 'value=Individual');
61 $this->click('field_name[1]');
62 $this->select('field_name[1]', 'value=last_name');
63 $this->click("//option[@value='Individual']");
64 $this->click('visibility');
65 $this->select('visibility', 'value=Public Pages');
66 $this->click('is_searchable');
67 $this->click('in_selector');
69 $this->click('_qf_Field_next_new-bottom');
70 $this->waitForPageToLoad($this->getTimeoutMsec());
72 $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Last Name' has been saved to '$profileTitle'.");
73 $this->waitForText('crm-notification-container', 'You can add another profile field.');
76 $this->click('field_name[0]');
77 $this->select('field_name[0]', 'value=Contact');
78 $this->click('field_name[1]');
79 $this->select('field_name[1]', 'value=email');
80 $this->click("//option[@value='Contact']");
81 $this->click('visibility');
82 $this->select('visibility', 'value=Public Pages');
83 $this->click('is_searchable');
84 $this->click('in_selector');
86 $this->click('_qf_Field_next_new-bottom');
87 $this->waitForPageToLoad($this->getTimeoutMsec());
89 $this->waitForText('crm-notification-container', "Your CiviCRM Profile Field 'Email' has been saved to '$profileTitle'.");
90 $this->waitForText('crm-notification-container', 'You can add another profile field.');
92 // Add Sample Custom Field.
93 $this->click('field_name[0]');
94 $this->select('field_name[0]', 'value=Individual');
95 $this->click('field_name[1]');
96 $this->select('field_name[1]', 'value=custom_1');
97 $this->click("//option[@value='Individual']");
98 $this->click('visibility');
99 $this->select('visibility', 'value=Public Pages');
100 $this->click('is_searchable');
101 $this->click('in_selector');
103 $this->clickLink('_qf_Field_next-bottom', "xpath=//div[@id='field_page']/div[1]/a[4]/span[text()='Use (create mode)']");
104 $this->click("xpath=//div[@id='field_page']/div[1]/a[4]/span[text()='Use (create mode)']");
106 $this->waitForElementPresent('_qf_Edit_next');
107 $lastName = substr(sha1(rand()), 0, 7);
110 $this->type('last_name', $lastName);
112 $this->type('email-Primary', "jhon@$lastName.com");
113 // Select Custom option
114 $this->click('CIVICRM_QFID_Edu_2');
115 $this->click('_qf_Edit_next');
116 $this->waitForPageToLoad($this->getTimeoutMsec());
118 $this->assertElementContainsText('css=span.msg-text', 'Your information has been saved.');
120 // Search Contact via profile.
121 $this->waitForElementPresent("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']");
122 $this->click("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']");
123 $this->waitForElementPresent("xpath=//div[@class='crm-block crm-form-block']");
124 $this->click("xpath=//div[@class='crm-block crm-form-block']");
126 $this->type('last_name', $lastName);
128 $this->type('email-Primary', "jhon@$lastName.com");
129 // Select Custom option
130 $this->click('CIVICRM_QFID_Edu_2');
131 $this->click('_qf_Search_refresh');
132 $this->waitForPageToLoad($this->getTimeoutMsec());
135 $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[2][text()='$lastName']"));
136 $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[3][text()='$lastName']"));
137 $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[4][text()='jhon@$lastName.com']"));
138 $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[5][text()='Education']"));
140 // Go back to Profile fields admin
141 $this->openCiviPage('admin/uf/group/field', "reset=1&action=browse&gid=$profileId");
143 // Edit first profile field
144 $this->waitForElementPresent("xpath=//table/tbody/tr[1]/td[9]");
145 $this->clickLink("xpath=//table/tbody/tr[1]/td[9]/span[1]/a[1]", '_qf_Field_next-bottom');
147 // sleep 5 to make sure jQuery is not hiding field after page load
148 // Because it tends to cause problems, all uses of sleep() must be justified in comments
149 // Sleep should never be used for wait for anything to load from the server
150 // Justification for this instance: FIXME
152 $this->assertTrue($this->isElementPresent("visibility"), 'Visibility field not present when editing existing profile field.');
153 $this->click("xpath=//tr[@id='profile_visibility']/td[1]/a");
154 $this->waitForElementPresent("xpath=//div[@id='crm-notification-container']/div/div[2]/p[2]");
155 $this->waitForText('crm-notification-container', 'Is this field hidden from other users');
156 $this->select('visibility', 'value=Public Pages and Listings');