Merge pull request #159 from lcdservices/master
[civicrm-core.git] / tests / phpunit / WebTest / Contact / UpdateProfileTest.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_UpdateProfileTest extends CiviSeleniumTestCase {
30
31 protected function setUp() {
32 parent::setUp();
33 }
34
35 function testUpdateProfile() {
36 // Create new via profile
37 include_once ('WebTest/Contact/AddViaProfileTest.php');
38 WebTest_Contact_AddViaProfileTest::testAddViaCreateProfile();
39
40 // Open profile for editing
41 $locationUrl = $this->getLocation();
42 $editUrl = str_replace('/view?', '/edit?', $locationUrl);
43 $this->open($editUrl);
44
45 // Modify profile field values
46 // contact details section
47 // name fields
48 $firstName = 'Ma' . substr(sha1(rand()), 0, 4);
49 $lastName = 'An' . substr(sha1(rand()), 0, 7);
50
51 $this->type("first_name", $firstName);
52 $this->type("last_name", $lastName);
53
54 //Address Details
55 $street = substr(sha1(rand()), 0, 4) . ' Main St.';
56 $this->type("street_address-1", $street);
57 $city = 'Ci ' . substr(sha1(rand()), 0, 4);
58 $this->type("city-1", $city);
59 $postalCode = substr(sha1(rand()), 0, 4);
60 $this->type("postal_code-1", $postalCode);
61 // Hard-coding to Arkansas, not sure best way to get random state.
62 $this->select("state_province-1", "value=1003");
63
64 // Clicking save.
65 $this->click("_qf_Edit_next");
66 $this->waitForPageToLoad($this->getTimeoutMsec());
67
68 // Confirm save was done.
69 $this->assertTrue($this->isTextPresent("Thank you. Your information has been saved."), 'In line ' . __LINE__);
70 $this->assertTrue($this->isTextPresent($firstName), 'In line ' . __LINE__);
71 $this->assertTrue($this->isTextPresent($lastName), 'In line ' . __LINE__);
72 $this->assertTrue($this->isTextPresent($street), 'In line ' . __LINE__);
73 $this->assertTrue($this->isTextPresent($city), 'In line ' . __LINE__);
74 $this->assertTrue($this->isTextPresent($postalCode), 'In line ' . __LINE__);
75 $this->assertTrue($this->isElementPresent("//div[@id='profilewrap1']/div[@id='crm-container']/div[7]/div[2][contains(text(), 'AR')]"));
76 }
77}
78
79