add missing comments - tests directory
[civicrm-core.git] / tests / phpunit / WebTest / Contact / UpdateProfileTest.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_UpdateProfileTest extends CiviSeleniumTestCase {
29
30 protected function setUp() {
31 parent::setUp();
32 }
33
34 function testUpdateProfile() {
35 // Create new via profile
36 include_once ('WebTest/Contact/AddViaProfileTest.php');
37 WebTest_Contact_AddViaProfileTest::testAddViaCreateProfile();
38
39 // Open profile for editing
40 $locationUrl = $this->getLocation();
41 $editUrl = str_replace('/view?', '/edit?', $locationUrl);
42 $this->open($editUrl);
43 $this->waitForPageToLoad($this->getTimeoutMsec());
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/div[7]/div[2][contains(text(), 'AR')]"));
76 }
77 }