3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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_Profile_ProfileGroupSubscriptionTest
32 class WebTest_Profile_ProfileGroupSubscriptionTest
extends CiviSeleniumTestCase
{
34 protected function setUp() {
38 function testProfileGroupSubscription() {
39 $this->webtestLogin();
42 $this->openCiviPage('admin/uf/group', 'reset=1');
44 $this->click('newCiviCRMProfile-top');
46 $this->waitForElementPresent('_qf_Group_next-bottom');
49 $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7);
50 $this->type('title', $profileTitle);
51 $this->click('uf_group_type_Profile');
53 //Drupal user account registration option
54 $this->click('CIVICRM_QFID_0_8');
56 //What to do upon duplicate match
57 $this->click('CIVICRM_QFID_0_2');
59 //Proximity search options
60 $this->click('CIVICRM_QFID_0_14');
62 // enable mapping for contact
63 $this->click('is_map');
65 // include a link in the listings to Edit profile fields
66 $this->click('is_edit_link');
68 //to view contacts' Drupal user account information
69 $this->click('is_uf_link');
72 $this->click('_qf_Group_next');
73 $this->waitForPageToLoad($this->getTimeoutMsec());
75 //check for profile create
76 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
78 //Add email field to profile
79 $this->waitForElementPresent("field_name[0]");
80 $this->click('field_name[0]');
81 $this->select('field_name[0]', 'value=Contact');
82 $this->click("//option[@value='Contact']");
84 $this->select('field_name[1]', 'value=email');
85 $this->click("//option[@value='email']");
88 $this->click('_qf_Field_next_new-top');
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 email field to profile
93 $this->click('field_name[0]');
94 $this->select('field_name[0]', 'value=Contact');
95 $this->click("//option[@value='Contact']");
97 $this->select('field_name[1]', 'value=group');
98 $this->click("//option[@value='group']");
101 $this->click('_qf_Field_next');
103 $this->waitForElementPresent("xpath=//div[@id='field_page']/div/a[4]/span");
105 //now use profile create mode for group subscription
106 $this->click("xpath=//div[@id='field_page']/div/a[4]/span");
108 $this->waitForElementPresent('email-Primary');
110 //check for group field
111 $this->assertElementContainsText('crm-profile-block', 'Group(s)', "Groups field was not found.");
113 //fill the subscription form
114 $randomEmail = substr(sha1(rand()), 0, 7) . "@example.com";
116 $this->type("email-Primary", $randomEmail);
118 // check advisory group ( may be we should create a separate group to test this)
119 $this->click("group_3");
121 $this->click('_qf_Edit_next');
124 // assert for subscription message
126 $this->isTextPresent("Your subscription request has been submitted for");
127 //check if profile is saved
128 $this->waitForText('crm-notification-container','Your information has been saved.');
130 // delete the profile
131 $this->openCiviPage('admin/uf/group', 'reset=1');
132 $this->_testdeleteProfile($profileTitle);
136 * @param $profileTitle
138 function _testdeleteProfile($profileTitle) {
139 $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[5]/a[text()='Delete']");
140 $this->click("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[5]/a[text()='Delete']");
141 $this->waitForElementPresent('_qf_Group_next-bottom');
142 $this->click('_qf_Group_next-bottom');
143 $this->waitForElementPresent('newCiviCRMProfile-bottom');
144 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");