Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 |
27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
28 | class WebTest_Profile_SearchTest extends CiviSeleniumTestCase { | |
29 | ||
30 | protected function setUp() { | |
31 | parent::setUp(); | |
32 | } | |
33 | ||
34 | function testSearchProfile() { | |
6a488035 TO |
35 | $this->webtestLogin(); |
36 | ||
6a488035 | 37 | // Add new profile. |
305515fb | 38 | $this->openCiviPage('admin/uf/group', 'reset=1'); |
76e86fd8 | 39 | |
6a488035 TO |
40 | $this->click('newCiviCRMProfile-bottom'); |
41 | ||
42 | $this->waitForElementPresent('_qf_Group_next-bottom'); | |
43 | ||
44 | //Name of profile | |
45 | $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7); | |
46 | $this->type('title', $profileTitle); | |
47 | ||
48 | //click on save | |
49 | $this->click('_qf_Group_next-bottom'); | |
50 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
51 | ||
52 | //check for profile create | |
305515fb | 53 | $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); |
6a488035 TO |
54 | |
55 | // Get profile id (gid) from URL | |
56 | $elements = $this->parseURL(); | |
57 | $profileId = $elements['queryString']['gid']; | |
58 | ||
59 | // Add Last Name field. | |
60 | $this->click('field_name[0]'); | |
61 | $this->select('field_name[0]', 'value=Individual'); | |
62 | $this->click('field_name[1]'); | |
63 | $this->select('field_name[1]', 'value=last_name'); | |
64 | $this->click("//option[@value='Individual']"); | |
65 | $this->click('visibility'); | |
66 | $this->select('visibility', 'value=Public Pages'); | |
67 | $this->click('is_searchable'); | |
68 | $this->click('in_selector'); | |
69 | // click on save | |
70 | $this->click('_qf_Field_next_new-bottom'); | |
71 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
72 | //check for field add | |
305515fb PJ |
73 | $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile Field 'Last Name' has been saved to '$profileTitle'."); |
74 | $this->assertElementContainsText('crm-notification-container', 'You can add another profile field.'); | |
75 | ||
6a488035 TO |
76 | // Add Email field. |
77 | $this->click('field_name[0]'); | |
78 | $this->select('field_name[0]', 'value=Contact'); | |
79 | $this->click('field_name[1]'); | |
80 | $this->select('field_name[1]', 'value=email'); | |
81 | $this->click("//option[@value='Contact']"); | |
82 | $this->click('visibility'); | |
83 | $this->select('visibility', 'value=Public Pages'); | |
84 | $this->click('is_searchable'); | |
85 | $this->click('in_selector'); | |
86 | // click on save | |
87 | $this->click('_qf_Field_next_new-bottom'); | |
88 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
89 | //check for field add | |
305515fb | 90 | $this->assertElementContainsText('crm-notification-container', "Your CiviCRM Profile Field 'Email' has been saved to '$profileTitle'."); |
76e86fd8 | 91 | $this->assertElementContainsText('crm-notification-container', 'You can add another profile field.'); |
6a488035 TO |
92 | |
93 | // Add Sample Custom Field. | |
94 | $this->click('field_name[0]'); | |
95 | $this->select('field_name[0]', 'value=Individual'); | |
96 | $this->click('field_name[1]'); | |
97 | $this->select('field_name[1]', 'value=custom_1'); | |
98 | $this->click("//option[@value='Individual']"); | |
99 | $this->click('visibility'); | |
100 | $this->select('visibility', 'value=Public Pages'); | |
101 | $this->click('is_searchable'); | |
102 | $this->click('in_selector'); | |
103 | // click on save | |
225a8648 | 104 | $this->clickLink('_qf_Field_next-bottom', "xpath=//div[@id='field_page']/div[1]/a[4]/span[text()='Use (create mode)']"); |
6a488035 TO |
105 | $this->click("xpath=//div[@id='field_page']/div[1]/a[4]/span[text()='Use (create mode)']"); |
106 | ||
107 | $this->waitForElementPresent('_qf_Edit_next'); | |
108 | $lastName = substr(sha1(rand()), 0, 7); | |
109 | ||
110 | // Fill Last Name | |
111 | $this->type('last_name', $lastName); | |
112 | // Fill Email | |
113 | $this->type('email-Primary', "jhon@$lastName.com"); | |
114 | // Select Custom option | |
115 | $this->click('CIVICRM_QFID_Edu_2'); | |
116 | $this->click('_qf_Edit_next'); | |
305515fb PJ |
117 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
118 | ||
119 | $this->assertElementContainsText('css=span.msg-text', 'Your information has been saved.'); | |
6a488035 TO |
120 | |
121 | // Search Contact via profile. | |
122 | $this->waitForElementPresent("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']"); | |
123 | $this->click("xpath=//div[@id='crm-container']//div/a[text()='» Back to Listings']"); | |
124 | $this->waitForElementPresent("xpath=//div[@class='crm-block crm-form-block']"); | |
125 | $this->click("xpath=//div[@class='crm-block crm-form-block']"); | |
126 | // Fill Last Name | |
127 | $this->type('last_name', $lastName); | |
128 | // Fill Email | |
129 | $this->type('email-Primary', "jhon@$lastName.com"); | |
130 | // Select Custom option | |
131 | $this->click('CIVICRM_QFID_Edu_2'); | |
132 | $this->click('_qf_Search_refresh'); | |
305515fb | 133 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
6a488035 TO |
134 | |
135 | // Verify Data. | |
305515fb PJ |
136 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[2][text()='$lastName']")); |
137 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[3][text()='$lastName']")); | |
138 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[4][text()='jhon@$lastName.com']")); | |
139 | $this->assertTrue($this->isElementPresent("xpath=//table/tbody/tr[2]/td[5][text()='Education']")); | |
6a488035 TO |
140 | |
141 | // Go back to Profile fields admin | |
305515fb | 142 | $this->openCiviPage('admin/uf/group/field', "reset=1&action=browse&gid=$profileId"); |
6a488035 TO |
143 | |
144 | // Edit first profile field | |
145 | $this->waitForElementPresent("xpath=//table/tbody/tr[1]/td[9]"); | |
225a8648 | 146 | $this->clickLink("xpath=//table/tbody/tr[1]/td[9]/span[1]/a[1]", '_qf_Field_next-bottom'); |
6a488035 TO |
147 | |
148 | // sleep 5 to make sure jQuery is not hiding field after page load | |
efb29358 CW |
149 | // Because it tends to cause problems, all uses of sleep() must be justified in comments |
150 | // Sleep should never be used for wait for anything to load from the server | |
151 | // Justification for this instance: FIXME | |
6a488035 TO |
152 | sleep(5); |
153 | $this->assertTrue($this->isElementPresent("visibility"), 'Visibility field not present when editing existing profile field.'); | |
154 | $this->click("xpath=//tr[@id='profile_visibility']/td[1]/a"); | |
155 | $this->waitForElementPresent("xpath=//div[@id='crm-notification-container']/div/div[2]/p[2]"); | |
305515fb | 156 | $this->assertElementContainsText('crm-notification-container', 'Is this field hidden from other users'); |
6a488035 TO |
157 | $this->select('visibility', 'value=Public Pages and Listings'); |
158 | } | |
42daf119 | 159 | } |