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