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_AddCmsUserTest extends CiviSeleniumTestCase { | |
30 | ||
31 | protected function setUp() { | |
32 | parent::setUp(); | |
33 | } | |
34 | ||
35 | function testAuthenticAddUser() { | |
36 | $this->open($this->sboxPath); | |
37 | ||
38 | $this->webtestLogin(TRUE); | |
39 | ||
40 | // Go directly to the URL of the screen that will Create User Authentically. | |
41 | $this->open($this->sboxPath . "admin/people/create"); | |
42 | ||
43 | ||
44 | $this->waitForElementPresent("edit-submit"); | |
45 | ||
46 | $name = "TestUserAuthenticated" . substr(sha1(rand()), 0, 4); | |
47 | $this->type("edit-name", $name); | |
48 | ||
49 | $emailId = substr(sha1(rand()), 0, 7) . '@web.com'; | |
50 | $this->type("edit-mail", $emailId); | |
51 | $this->type("edit-pass-pass1", "Test12345"); | |
52 | $this->type("edit-pass-pass2", "Test12345"); | |
53 | ||
54 | //Add profile Details | |
55 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
56 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
57 | ||
58 | $this->type("first_name", $firstName); | |
59 | $this->type("last_name", $lastName); | |
60 | ||
61 | //Address Details | |
62 | $this->type("street_address-1", "902C El Camino Way SW"); | |
63 | $this->type("city-1", "Dumfries"); | |
64 | $this->type("postal_code-1", "1234"); | |
65 | $this->select("state_province-1", "value=1019"); | |
66 | ||
67 | $this->click("edit-submit"); | |
68 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
69 | } | |
70 | ||
71 | function testAnonymousAddUser() { | |
72 | // This is the path where our testing install resides. | |
73 | // The rest of URL is defined in CiviSeleniumTestCase base class, in | |
74 | // class attributes. | |
75 | $this->open($this->sboxPath); | |
76 | ||
77 | // Make sure Drupal account settings allow visitors to register for account w/o admin approval | |
78 | // login as admin | |
79 | $this->webtestLogin(TRUE); | |
80 | $this->open($this->sboxPath . "admin/config/people/accounts"); | |
81 | $this->waitForElementPresent("edit-submit"); | |
82 | ||
83 | $this->click('edit-user-register-1'); | |
84 | $this->click('edit-user-email-verification'); | |
85 | $this->click('edit-submit'); | |
86 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
87 | // logout | |
88 | $this->open($this->sboxPath . 'civicrm/logout?reset=1'); | |
89 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
90 | ||
91 | // Go directly to the URL of the screen that will Create User Anonymously. | |
92 | $this->open($this->sboxPath . "user/register"); | |
93 | ||
94 | $this->waitForElementPresent("edit-submit"); | |
95 | $name = "TestUserAnonymous" . substr(sha1(rand()), 0, 7); | |
96 | $this->type("edit-name", $name); | |
97 | $emailId = substr(sha1(rand()), 0, 7) . '@web.com'; | |
98 | $this->type("edit-mail", $emailId); | |
99 | ||
100 | ||
101 | //Add profile Details | |
102 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
103 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
104 | $this->type("first_name", $firstName); | |
105 | $this->type("last_name", $lastName); | |
106 | ||
107 | //Address Details | |
108 | $this->type("street_address-1", "902C El Camino Way SW"); | |
109 | $this->type("city-1", "Dumfries"); | |
110 | $this->type("postal_code-1", "1234"); | |
111 | $this->assertTrue($this->isTextPresent("United States")); | |
112 | $this->select("state_province-1", "value=1019"); | |
113 | ||
114 | $this->click("edit-submit"); | |
115 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
116 | $this->assertTrue($this->isTextPresent("A welcome message with further instructions has been sent to your e-mail address.")); | |
117 | ||
118 | $this->webtestLogin(); | |
119 | ||
120 | $this->open($this->sboxPath . "civicrm/contact/search?reset=1"); | |
121 | $this->waitForElementPresent("_qf_Basic_refresh"); | |
122 | $this->type("sort_name", $emailId); | |
123 | $this->click("_qf_Basic_refresh"); | |
124 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
125 | ||
126 | $this->assertTrue($this->isTextPresent($emailId)); | |
127 | $this->assertTrue($this->isTextPresent($lastName . ', ' . $firstName)); | |
128 | $this->assertTrue($this->isTextPresent("902C El Camino Way SW")); | |
129 | $this->assertTrue($this->isTextPresent("Dumfries")); | |
130 | $this->assertTrue($this->isTextPresent("1234")); | |
131 | } | |
132 | } | |
133 |