Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
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 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Profile_ProfileGroupSubscriptionTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Profile_ProfileGroupSubscriptionTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
00be9182 | 38 | public function testProfileGroupSubscription() { |
6a488035 TO |
39 | $this->webtestLogin(); |
40 | ||
42daf119 | 41 | // Add new profile. |
305515fb | 42 | $this->openCiviPage('admin/uf/group', 'reset=1'); |
76e86fd8 | 43 | |
6a488035 TO |
44 | $this->click('newCiviCRMProfile-top'); |
45 | ||
46 | $this->waitForElementPresent('_qf_Group_next-bottom'); | |
47 | ||
48 | //Name of profile | |
49 | $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7); | |
50 | $this->type('title', $profileTitle); | |
91a8b457 | 51 | $this->click('uf_group_type_Profile'); |
6a488035 TO |
52 | |
53 | //Drupal user account registration option | |
54 | $this->click('CIVICRM_QFID_0_8'); | |
55 | ||
56 | //What to do upon duplicate match | |
57 | $this->click('CIVICRM_QFID_0_2'); | |
58 | ||
59 | //Proximity search options | |
60 | $this->click('CIVICRM_QFID_0_14'); | |
61 | ||
59474c0a | 62 | // enable mapping for contact |
6a488035 TO |
63 | $this->click('is_map'); |
64 | ||
65 | // include a link in the listings to Edit profile fields | |
66 | $this->click('is_edit_link'); | |
67 | ||
68 | //to view contacts' Drupal user account information | |
69 | $this->click('is_uf_link'); | |
70 | ||
71 | //click on save | |
72 | $this->click('_qf_Group_next'); | |
73 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
74 | ||
75 | //check for profile create | |
6c5f7368 | 76 | $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now."); |
6a488035 TO |
77 | |
78 | //Add email field to profile | |
bf2c3b74 | 79 | $this->waitForElementPresent("field_name[0]"); |
6a488035 TO |
80 | $this->click('field_name[0]'); |
81 | $this->select('field_name[0]', 'value=Contact'); | |
82 | $this->click("//option[@value='Contact']"); | |
83 | ||
84 | $this->select('field_name[1]', 'value=email'); | |
85 | $this->click("//option[@value='email']"); | |
86 | ||
87 | //click on save | |
88 | $this->click('_qf_Field_next_new-top'); | |
bf2c3b74 | 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.'); | |
6a488035 TO |
91 | |
92 | //Add email field to profile | |
93 | $this->click('field_name[0]'); | |
94 | $this->select('field_name[0]', 'value=Contact'); | |
95 | $this->click("//option[@value='Contact']"); | |
96 | ||
97 | $this->select('field_name[1]', 'value=group'); | |
98 | $this->click("//option[@value='group']"); | |
99 | ||
100 | //click on save | |
101 | $this->click('_qf_Field_next'); | |
102 | ||
bf2c3b74 | 103 | $this->waitForElementPresent("xpath=//div[@id='field_page']/div/a[4]/span"); |
6a488035 TO |
104 | |
105 | //now use profile create mode for group subscription | |
305515fb | 106 | $this->click("xpath=//div[@id='field_page']/div/a[4]/span"); |
6a488035 TO |
107 | |
108 | $this->waitForElementPresent('email-Primary'); | |
109 | ||
110 | //check for group field | |
305515fb | 111 | $this->assertElementContainsText('crm-profile-block', 'Group(s)', "Groups field was not found."); |
6a488035 TO |
112 | |
113 | //fill the subscription form | |
59474c0a | 114 | $randomEmail = substr(sha1(rand()), 0, 7) . "@example.com"; |
6a488035 | 115 | |
59474c0a | 116 | $this->type("email-Primary", $randomEmail); |
6a488035 TO |
117 | |
118 | // check advisory group ( may be we should create a separate group to test this) | |
305515fb | 119 | $this->click("group_3"); |
76e86fd8 | 120 | |
6a488035 TO |
121 | $this->click('_qf_Edit_next'); |
122 | ||
6a488035 | 123 | // assert for subscription message |
6a488035 | 124 | |
91a8b457 | 125 | $this->isTextPresent("Your subscription request has been submitted for"); |
6a488035 | 126 | //check if profile is saved |
64b211dd | 127 | $this->isTextPresent("Your information has been saved."); |
6a488035 TO |
128 | |
129 | // delete the profile | |
305515fb | 130 | $this->openCiviPage('admin/uf/group', 'reset=1'); |
6a488035 TO |
131 | $this->_testdeleteProfile($profileTitle); |
132 | } | |
133 | ||
4cbe18b8 EM |
134 | /** |
135 | * @param $profileTitle | |
136 | */ | |
00be9182 | 137 | public function _testdeleteProfile($profileTitle) { |
5c80555f WA |
138 | $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div[1]/table/tbody//tr/td[1]/div[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul//li/a[text()='Delete']"); |
139 | $this->click("xpath=//div[@id='user-profiles']/div/div[1]/table/tbody//tr/td[1]/div[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul//li/a[text()='Delete']"); | |
6a488035 TO |
140 | $this->waitForElementPresent('_qf_Group_next-bottom'); |
141 | $this->click('_qf_Group_next-bottom'); | |
142 | $this->waitForElementPresent('newCiviCRMProfile-bottom'); | |
6c5f7368 | 143 | $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted."); |
6a488035 TO |
144 | } |
145 | } |