version fixes
[civicrm-core.git] / tests / phpunit / WebTest / Profile / ProfileGroupSubscriptionTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 +--------------------------------------------------------------------+
d25dd0ee 25 */
6a488035 26
6a488035 27require_once 'CiviTest/CiviSeleniumTestCase.php';
e9479dcf
EM
28
29/**
30 * Class WebTest_Profile_ProfileGroupSubscriptionTest
31 */
6a488035
TO
32class 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'.");
6a488035
TO
90
91 //Add email field to profile
92 $this->click('field_name[0]');
93 $this->select('field_name[0]', 'value=Contact');
94 $this->click("//option[@value='Contact']");
95
96 $this->select('field_name[1]', 'value=group');
97 $this->click("//option[@value='group']");
98
99 //click on save
100 $this->click('_qf_Field_next');
101
bf2c3b74 102 $this->waitForElementPresent("xpath=//div[@id='field_page']/div/a[4]/span");
6a488035
TO
103
104 //now use profile create mode for group subscription
305515fb 105 $this->click("xpath=//div[@id='field_page']/div/a[4]/span");
6a488035
TO
106
107 $this->waitForElementPresent('email-Primary');
108
109 //check for group field
305515fb 110 $this->assertElementContainsText('crm-profile-block', 'Group(s)', "Groups field was not found.");
6a488035
TO
111
112 //fill the subscription form
59474c0a 113 $randomEmail = substr(sha1(rand()), 0, 7) . "@example.com";
6a488035 114
59474c0a 115 $this->type("email-Primary", $randomEmail);
6a488035
TO
116
117 // check advisory group ( may be we should create a separate group to test this)
305515fb 118 $this->click("group_3");
76e86fd8 119
6a488035
TO
120 $this->click('_qf_Edit_next');
121
6a488035 122 // assert for subscription message
6a488035 123
91a8b457 124 $this->isTextPresent("Your subscription request has been submitted for");
6a488035 125 //check if profile is saved
64b211dd 126 $this->isTextPresent("Your information has been saved.");
6a488035
TO
127
128 // delete the profile
305515fb 129 $this->openCiviPage('admin/uf/group', 'reset=1');
6a488035
TO
130 $this->_testdeleteProfile($profileTitle);
131 }
132
4cbe18b8
EM
133 /**
134 * @param $profileTitle
135 */
00be9182 136 public function _testdeleteProfile($profileTitle) {
5c80555f
WA
137 $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']");
138 $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
139 $this->waitForElementPresent('_qf_Group_next-bottom');
140 $this->click('_qf_Group_next-bottom');
141 $this->waitForElementPresent('newCiviCRMProfile-bottom');
6c5f7368 142 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");
6a488035 143 }
96025800 144
6a488035 145}