Import from SVN (r45945, r596)
[civicrm-core.git] / tests / phpunit / WebTest / Contact / DupeContactTest.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
27
28require_once 'CiviTest/CiviSeleniumTestCase.php';
29class WebTest_Contact_DupeContactTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testDuplicateContactAdd() {
36 // This is the path where our testing install resides.
37 // The rest of URL is defined in CiviSeleniumTestCase base class, in
38 // class attributes.
39 $this->open($this->sboxPath);
40
41 // Logging in. Remember to wait for page to load. In most cases,
42 // you can rely on 30000 as the value that allows your test to pass, however,
43 // sometimes your test might fail because of this. In such cases, it's better to pick one element
44 // somewhere at the end of page and use waitForElementPresent on it - this assures you, that whole
45 // page contents loaded and you can continue your test execution.
46 $this->webtestLogin();
47
48 // Go directly to the URL of New Individual.
49 $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
50 $this->waitForPageToLoad($this->getTimeoutMsec());
51
52 $firstName = substr(sha1(rand()), 0, 7);
53 $lastName1 = substr(sha1(rand()), 0, 7);
54 $email = "{$firstName}@example.com";
55 $lastName2 = substr(sha1(rand()), 0, 7);
56
57 //contact details section
58 //select prefix
59 $this->click("prefix_id");
60 $this->select("prefix_id", "value=3");
61
62 //fill in first name
63 $this->type("first_name", "$firstName");
64
65 //fill in last name
66 $this->type("last_name", "$lastName1");
67
68 //fill in email
69 $this->type("email_1_email", "$email");
70
71 //check for matching contact
72 //$this->click("_qf_Contact_refresh_dedupe");
73 //$this->waitForPageToLoad($this->getTimeoutMsec());
74
75 // Clicking save.
76 $this->click("_qf_Contact_upload_view");
77 $this->waitForPageToLoad($this->getTimeoutMsec());
78 $this->assertElementContainsText('crm-notification-container', "Contact Saved");
79
80 // Go directly to the URL of New Individual.
81 $this->open($this->sboxPath . "civicrm/contact/add?reset=1&ct=Individual");
82 $this->waitForPageToLoad($this->getTimeoutMsec());
83
84 //contact details section
85
86
87 //fill in first name
88 $this->type("first_name", "$firstName");
89
90 //fill in last name
91 $this->type("last_name", "$lastName1");
92
93 //fill in email
94 $this->type("email_1_email", "$email");
95
96 // Clicking save.
97 $this->click("_qf_Contact_upload_view");
98 $this->waitForPageToLoad($this->getTimeoutMsec());
99
100 $this->isTextPresent("Please correct the following errors in the form fields below: One matching contact was found. You can View or Edit the existing contact, or Merge this contact with an existing contact.");
101 }
102}
103
104