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_ProfileGroupSubscriptionTest
extends CiviSeleniumTestCase
{
30 protected function setUp() {
34 function testProfileGroupSubscription() {
35 $this->webtestLogin();
38 $this->openCiviPage('admin/uf/group', 'reset=1');
40 $this->click('newCiviCRMProfile-top');
42 $this->waitForElementPresent('_qf_Group_next-bottom');
45 $profileTitle = 'profile_' . substr(sha1(rand()), 0, 7);
46 $this->type('title', $profileTitle);
48 //Drupal user account registration option
49 $this->click('CIVICRM_QFID_0_8');
51 //What to do upon duplicate match
52 $this->click('CIVICRM_QFID_0_2');
54 //Proximity search options
55 $this->click('CIVICRM_QFID_0_14');
57 // enable maping for contact
58 $this->click('is_map');
60 // include a link in the listings to Edit profile fields
61 $this->click('is_edit_link');
63 //to view contacts' Drupal user account information
64 $this->click('is_uf_link');
67 $this->click('_qf_Group_next');
68 $this->waitForPageToLoad($this->getTimeoutMsec());
70 //check for profile create
71 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
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']");
78 $this->select('field_name[1]', 'value=email');
79 $this->click("//option[@value='email']");
82 $this->click('_qf_Field_next_new-top');
83 $this->waitForPageToLoad($this->getTimeoutMsec());
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']");
90 $this->select('field_name[1]', 'value=group');
91 $this->click("//option[@value='group']");
94 $this->click('_qf_Field_next');
96 $this->waitForPageToLoad($this->getTimeoutMsec());
98 //now use profile create mode for group subscription
99 $this->click("xpath=//div[@id='field_page']/div/a[4]/span");
101 $this->waitForElementPresent('email-Primary');
103 //check for group field
104 $this->assertElementContainsText('crm-profile-block', 'Group(s)', "Groups field was not found.");
106 //fill the subscription form
107 $radomEmail = substr(sha1(rand()), 0, 7) . "@example.com";
109 $this->type("email-Primary", $radomEmail);
111 // check advisory group ( may be we should create a separate group to test this)
112 $this->click("group_3");
114 $this->click('_qf_Edit_next');
116 $this->waitForPageToLoad($this->getTimeoutMsec());
118 // assert for subscription message
119 $this->assertElementContainsText('css=div.messages', "Your subscription request has been submitted for group ", "Subscription message is not shown");
121 //check if profile is saved
122 $this->assertElementContainsText('css=span.msg-text', 'Your information has been saved.', 'Profile is not saved');
124 // delete the profile
125 $this->openCiviPage('admin/uf/group', 'reset=1');
126 $this->_testdeleteProfile($profileTitle);
129 function _testdeleteProfile($profileTitle) {
130 $this->waitForElementPresent("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[4]/a[text()='Delete']");
131 $this->click("xpath=//div[@id='user-profiles']/div/div/table/tbody//tr/td/span[text() = '$profileTitle']/../../td[7]/span[2][text()='more']/ul/li[4]/a[text()='Delete']");
132 $this->waitForElementPresent('_qf_Group_next-bottom');
133 $this->click('_qf_Group_next-bottom');
134 $this->waitForElementPresent('newCiviCRMProfile-bottom');
135 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");