Commit | Line | Data |
---|---|---|
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 | ||
28 | require_once 'CiviTest/CiviSeleniumTestCase.php'; | |
29 | class 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. | |
d8bd5fb9 | 49 | $this->openCiviPage('contact/add', 'reset=1&ct=Individual'); |
6a488035 TO |
50 | |
51 | $firstName = substr(sha1(rand()), 0, 7); | |
52 | $lastName1 = substr(sha1(rand()), 0, 7); | |
53 | $email = "{$firstName}@example.com"; | |
54 | $lastName2 = substr(sha1(rand()), 0, 7); | |
55 | ||
56 | //contact details section | |
57 | //select prefix | |
58 | $this->click("prefix_id"); | |
59 | $this->select("prefix_id", "value=3"); | |
60 | ||
61 | //fill in first name | |
62 | $this->type("first_name", "$firstName"); | |
63 | ||
64 | //fill in last name | |
65 | $this->type("last_name", "$lastName1"); | |
66 | ||
67 | //fill in email | |
68 | $this->type("email_1_email", "$email"); | |
69 | ||
70 | //check for matching contact | |
71 | //$this->click("_qf_Contact_refresh_dedupe"); | |
72 | //$this->waitForPageToLoad($this->getTimeoutMsec()); | |
73 | ||
74 | // Clicking save. | |
75 | $this->click("_qf_Contact_upload_view"); | |
76 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
77 | $this->assertElementContainsText('crm-notification-container', "Contact Saved"); | |
78 | ||
79 | // Go directly to the URL of New Individual. | |
d8bd5fb9 | 80 | $this->openCiviPage('contact/add' , 'reset=1&ct=Individual'); |
6a488035 TO |
81 | |
82 | //contact details section | |
83 | ||
84 | ||
85 | //fill in first name | |
86 | $this->type("first_name", "$firstName"); | |
87 | ||
88 | //fill in last name | |
89 | $this->type("last_name", "$lastName1"); | |
90 | ||
91 | //fill in email | |
92 | $this->type("email_1_email", "$email"); | |
93 | ||
94 | // Clicking save. | |
95 | $this->click("_qf_Contact_upload_view"); | |
96 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
97 | ||
d8bd5fb9 | 98 | $this->assertElementContainsText("css=.notify-content", "Please correct the following errors in the form fields below: One matching contact was found. You can View or Edit the existing contact."); |
6a488035 TO |
99 | } |
100 | } | |
101 | ||
102 |