Update Copywrite year to be 2019
[civicrm-core.git] / tests / phpunit / WebTest / Profile / DedupeTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
2fe49090 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
6b83d5bd 6 | Copyright CiviCRM LLC (c) 2004-2019 |
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_DedupeTest
31 */
6a488035
TO
32class WebTest_Profile_DedupeTest extends CiviSeleniumTestCase {
33
34 protected function setUp() {
35 parent::setUp();
36 }
37
00be9182 38 public function testProfileCreateDupeStrictDefault() {
6a488035 39 // lets give profile related permision to anonymous user.
92915c55
TO
40 $permission = array(
41 'edit-1-profile-create',
42 'edit-1-profile-edit',
43 'edit-1-profile-listings',
7c550ca0 44 'edit-1-profile-view',
92915c55 45 );
6a488035
TO
46 $this->changePermissions($permission);
47
42daf119
CW
48 // Log in as normal user
49 $this->webtestLogin();
50
38bf8139 51 $this->openCiviPage('contact/add', 'reset=1&ct=Individual');
6a488035
TO
52
53 $firstName = "John" . substr(sha1(rand()), 0, 7);
42daf119
CW
54 $lastName = "Smith" . substr(sha1(rand()), 0, 7);
55 $email = $firstName . "@" . $lastName . ".com";
6a488035
TO
56 // fill in first name
57 $this->type("first_name", $firstName);
58
59 // fill in last name
60 $this->type("last_name", $lastName);
61
62 // fill in email
63 $this->type("email_1_email", $email);
64
65 // Clicking save.
66 $this->click("_qf_Contact_upload_view");
67 $this->waitForPageToLoad($this->getTimeoutMsec());
68 $individualName = $this->getText("xpath=//div[@class='crm-summary-display_name']");
6c5f7368 69 $this->waitForText('crm-notification-container', "$individualName has been created.");
6a488035
TO
70
71 // submit dupe using profile/create as anonymous
38bf8139 72 $this->openCiviPage('profile/create', 'gid=4&reset=1', '_qf_Edit_next');
6a488035
TO
73
74 $firstName = "John" . substr(sha1(rand()), 0, 7);
75 $lastName = "Smith" . substr(sha1(rand()), 0, 7);
76
77 // fill in first name
78 $this->type("first_name", $firstName);
79
80 // fill in last name
81 $this->type("last_name", $lastName);
82
83 // fill in email
84 $this->type("email-Primary", $email);
85
86 // click save
87 $this->click("_qf_Edit_next");
88 $this->waitForTextPresent("A record already exists with the same information.");
89 }
96025800 90
42daf119 91}