Merge pull request #287 from totten/givi
[civicrm-core.git] / tests / phpunit / WebTest / Profile / ProfileAddTest.php
CommitLineData
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
27require_once 'CiviTest/CiviSeleniumTestCase.php';
28class WebTest_Profile_ProfileAddTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testAddNewProfile() {
6a488035
TO
35 $this->webtestLogin();
36
42daf119 37 // Add new profile.
38bf8139 38 $this->openCiviPage('admin/uf/group', 'reset=1');
6a488035
TO
39
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 //profile Used for
49 $this->click('uf_group_type_User Registration');
50 $this->click('uf_group_type_User Account');
51
52 //Profile Advance Settings
53 $this->click("//form[@id='Group']/div[2]/div[2]/div[1]");
54
55 //Select a group if you are using this profile for search and listings.
56 $this->select('group', 'value=1');
57
58 //Select a group if you are using this profile for adding new contacts.
59 $this->select('add_contact_to_group', 'value=1');
60
61 //If you want member(s) of your organization to receive a
62 //notification email whenever this Profile
63 //form is used to enter or update contact information, enter one or more email addresses here.
64 $this->type('notify', 'This is notify email');
65
66 //If you are using this profile as a contact signup or edit
67 //form, and want to redirec the user to a static URL after
68 //they've submitted the form - enter the complete URL here.
69 $this->type('post_URL', 'This is Post Url');
70
71 // If you are using this profile as a contact signup or edit
72 // form, and want to redirect the user to a
73 //static URL if they click the Cancel button - enter the complete URL here.
74 $this->type('cancel_URL', 'This is cancle Url');
75
76 //reCaptcha settings
77 $this->click('add_captcha');
78
79 //Drupal user account registration option
80 $this->click('CIVICRM_QFID_0_8');
81
82 //What to do upon duplicate match
83 $this->click('CIVICRM_QFID_0_2');
84
85 //Proximity search options
86 $this->click('CIVICRM_QFID_0_14');
87
88 // enable maping for contact
89 $this->click('is_map');
90
91 // include a link in the listings to Edit profile fields
92 $this->click('is_edit_link');
93
94 //to view contacts' Drupal user account information
95 $this->click('is_uf_link');
96
97 //click on save
98 $this->click('_qf_Group_next');
99 $this->waitForPageToLoad($this->getTimeoutMsec());
100
101 //check for profile create
6c5f7368 102 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been added. You can add fields to this profile now.");
6a488035
TO
103
104 //Add field to profile
105 $this->click('field_name[0]');
106 $this->select('field_name[0]', 'value=Contact');
107 $this->click("//option[@value='Contact']");
108 $this->click('is_required');
109 $this->type('help_post', 'This is help for profile field');
110
111 //click on save
112 $this->click('_qf_Field_next');
113 $this->waitForPageToLoad($this->getTimeoutMsec());
114
115 // delete the profile
38bf8139 116 $this->openCiviPage('admin/uf/group', 'reset=1');
6a488035
TO
117 $this->_testdeleteProfile($profileTitle);
118 }
119
120 function _testdeleteProfile($profileTitle) {
121 //$this->waitForPageToLoad($this->getTimeoutMsec());
122 $this->waitForElementPresent("//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']");
123 $this->click("//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']");
124
125 $this->waitForElementPresent('_qf_Group_next-bottom');
126 $this->click('_qf_Group_next-bottom');
127 $this->waitForElementPresent('newCiviCRMProfile-bottom');
6c5f7368 128 $this->waitForText('crm-notification-container', "Your CiviCRM Profile '{$profileTitle}' has been deleted.");
6a488035 129 }
42daf119 130}