copyright and version fixes
[civicrm-core.git] / tests / phpunit / WebTest / Contact / EditContactTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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 require_once 'CiviTest/CiviSeleniumTestCase.php';
28 class WebTest_Contact_EditContactTest extends CiviSeleniumTestCase {
29 protected function setUp() {
30 parent::setUp();
31 }
32
33 function testEditContact() {
34 // Log in using webtestLogin() method
35 $this->webtestLogin();
36
37 // create contact
38 $firstName = 'WebTest' . substr(sha1(rand()), 0, 7);
39 $lastName = 'ContactEdit' . substr(sha1(rand()), 0, 7);
40 $this->openCiviPage("contact/add", "reset=1&ct=Individual");
41 $this->type("first_name",$firstName);
42 $this->type("last_name",$lastName);
43
44 //fill in phone 1
45 $this->type("phone_1_phone", "111113333");
46 $this->type("phone_1_phone_ext", "101");
47
48 //fill in phone 2
49
50 $this->click("//a[@id='addPhone']");
51 $this->type("phone_2_phone", "23213333");
52 $this->type("phone_2_phone_ext", "165");
53 $this->select('phone_2_location_type_id', 'value=2');
54
55 //fill in phone 3
56 $this->click("//a[@id='addPhone']");
57 $this->type("phone_3_phone", "2321877699");
58 $this->type("phone_3_phone_ext", "195");
59 $this->select('phone_3_location_type_id', 'value=2');
60
61 //fill in phone 4
62 $this->click("//a[@id='addPhone']");
63 $this->type("phone_4_phone", "2321398766");
64 $this->type("phone_4_phone_ext", "198");
65 $this->select('phone_4_location_type_id', 'value=2');
66
67 // Submit form
68 $this->click("_qf_Contact_upload_view-bottom");
69 $this->waitForElementPresent('css=.crm-inline-edit-container.crm-edit-ready');
70
71 //assert
72 $this->assertTextPresent("111113333 ext. 101");
73 $this->assertTextPresent("23213333 ext. 165");
74 $this->assertTextPresent("2321877699 ext. 195");
75 $this->assertTextPresent("2321398766 ext. 198");
76
77 //Edit COntact
78 $cid = $this->urlArg('cid');
79 $this->openCiviPage("contact/add", "reset=1&action=update&cid={$cid}");
80
81 //Edit in phone 1
82 $this->type("phone_1_phone", "12223333");
83 $this->type("phone_1_phone_ext", "100");
84
85 //Edit in phone 2
86 $this->type("phone_2_phone", "2321800000");
87 $this->type("phone_2_phone_ext", "111");
88 $this->select('phone_2_location_type_id', 'value=3');
89
90 //Edit in phone 3
91 $this->type("phone_3_phone", "777777699");
92 $this->type("phone_3_phone_ext", "197");
93 $this->select('phone_3_location_type_id', 'value=1');
94
95 //Edit in phone 4
96 $this->type("phone_4_phone", "2342322222");
97 $this->type("phone_4_phone_ext", "198");
98 $this->select('phone_4_location_type_id', 'value=3');
99
100 // Submit form
101 $this->click("_qf_Contact_upload_view-bottom");
102 $this->waitForElementPresent('css=.crm-inline-edit-container.crm-edit-ready');
103
104 //assert
105 $this->assertTextPresent("12223333 ext. 100");
106 $this->assertTextPresent("2321800000 ext. 111");
107 $this->assertTextPresent("777777699 ext. 197");
108 $this->assertTextPresent("2342322222 ext. 198");
109
110 }
111 }