Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
06a1bc01 | 4 | | CiviCRM version 4.5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | ||
6a488035 | 27 | require_once 'CiviTest/CiviSeleniumTestCase.php'; |
e9479dcf EM |
28 | |
29 | /** | |
30 | * Class WebTest_Contact_AddCmsUserTest | |
31 | */ | |
6a488035 TO |
32 | class WebTest_Contact_AddCmsUserTest extends CiviSeleniumTestCase { |
33 | ||
34 | protected function setUp() { | |
35 | parent::setUp(); | |
36 | } | |
37 | ||
38 | function testAuthenticAddUser() { | |
6a488035 | 39 | |
42daf119 | 40 | $this->webtestLogin('admin'); |
6a488035 | 41 | |
61ae30d9 | 42 | $this->open($this->sboxPath . 'admin/people/create'); |
6a488035 | 43 | |
61ae30d9 | 44 | $this->waitForElementPresent('edit-submit'); |
6a488035 | 45 | |
61ae30d9 | 46 | $name = 'TestUserAuthenticated' . substr(sha1(rand()), 0, 4); |
47 | $this->type('edit-name', $name); | |
6a488035 TO |
48 | |
49 | $emailId = substr(sha1(rand()), 0, 7) . '@web.com'; | |
61ae30d9 | 50 | $this->type('edit-mail', $emailId); |
51 | $this->type('edit-pass-pass1', 'Test12345'); | |
52 | $this->type('edit-pass-pass2', 'Test12345'); | |
6a488035 TO |
53 | |
54 | //Add profile Details | |
55 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
56 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
61ae30d9 | 57 | $this->waitForElementPresent('first_name'); |
58 | $this->type('first_name', $firstName); | |
59 | $this->type('last_name', $lastName); | |
6a488035 TO |
60 | |
61 | //Address Details | |
61ae30d9 | 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'); | |
6a488035 | 66 | |
61ae30d9 | 67 | $this->click('edit-submit'); |
6a488035 TO |
68 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
69 | } | |
70 | ||
71 | function testAnonymousAddUser() { | |
6a488035 TO |
72 | // Make sure Drupal account settings allow visitors to register for account w/o admin approval |
73 | // login as admin | |
42daf119 | 74 | $this->webtestLogin('admin'); |
61ae30d9 | 75 | $this->open($this->sboxPath . 'admin/config/people/accounts'); |
76 | $this->waitForElementPresent('edit-submit'); | |
6a488035 TO |
77 | |
78 | $this->click('edit-user-register-1'); | |
79d6583c | 79 | $this->check('edit-user-email-verification'); |
6a488035 TO |
80 | $this->click('edit-submit'); |
81 | $this->waitForPageToLoad($this->getTimeoutMsec()); | |
82 | // logout | |
42daf119 | 83 | $this->webtestLogout(); |
6a488035 | 84 | |
61ae30d9 | 85 | $this->open($this->sboxPath . 'user/register'); |
6a488035 | 86 | |
61ae30d9 | 87 | $this->waitForElementPresent('edit-submit'); |
88 | $name = 'TestUserAnonymous' . substr(sha1(rand()), 0, 7); | |
89 | $this->type('edit-name', $name); | |
6a488035 | 90 | $emailId = substr(sha1(rand()), 0, 7) . '@web.com'; |
61ae30d9 | 91 | $this->type('edit-mail', $emailId); |
6a488035 | 92 | |
6a488035 TO |
93 | //Add profile Details |
94 | $firstName = 'Ma' . substr(sha1(rand()), 0, 4); | |
95 | $lastName = 'An' . substr(sha1(rand()), 0, 7); | |
f31477d7 | 96 | $this->waitForElementPresent('first_name'); |
61ae30d9 | 97 | $this->type('first_name', $firstName); |
98 | $this->type('last_name', $lastName); | |
6a488035 TO |
99 | |
100 | //Address Details | |
61ae30d9 | 101 | $this->type('street_address-1', '902C El Camino Way SW'); |
102 | $this->type('city-1', 'Dumfries'); | |
103 | $this->type('postal_code-1', '1234'); | |
104 | $this->assertTrue($this->isTextPresent('United States')); | |
105 | $this->select('state_province-1', 'value=1019'); | |
6a488035 | 106 | |
61ae30d9 | 107 | $this->click('edit-submit'); |
6a488035 | 108 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
0bd37c06 CW |
109 | |
110 | // In case the site is set up to login immediately upon registration | |
42daf119 | 111 | $this->webtestLogout(); |
6a488035 TO |
112 | |
113 | $this->webtestLogin(); | |
114 | ||
61ae30d9 | 115 | $this->openCiviPage('contact/search', 'reset=1', '_qf_Basic_refresh'); |
116 | $this->type('sort_name', $emailId); | |
117 | $this->click('_qf_Basic_refresh'); | |
6a488035 TO |
118 | $this->waitForPageToLoad($this->getTimeoutMsec()); |
119 | ||
b9715b8a CW |
120 | $this->assertElementContainsText('css=.crm-search-results', $emailId); |
121 | $this->assertElementContainsText('css=.crm-search-results', $lastName . ', ' . $firstName); | |
61ae30d9 | 122 | $this->assertElementContainsText('css=.crm-search-results', '902C El Camino Way SW'); |
123 | $this->assertElementContainsText('css=.crm-search-results', 'Dumfries'); | |
124 | $this->assertElementContainsText('css=.crm-search-results', '1234'); | |
6a488035 TO |
125 | } |
126 | } | |
127 |