Révision 55670b15
Ajouté par Assos Assos il y a presque 10 ans
drupal7/sites/all/modules/honeypot/honeypot.test | ||
---|---|---|
98 | 98 |
$this->drupalPost('user/register', $edit, t('Create new account')); |
99 | 99 |
|
100 | 100 |
// Form should have error message. |
101 |
$this->assertText(t('There was a problem with your form submission. Please wait'), 'Registration form protected by time limit.'); |
|
101 |
$this->assertText(t('There was a problem with your form submission. Please wait 6 seconds and try again.'), 'Registration form protected by time limit.');
|
|
102 | 102 |
} |
103 | 103 |
|
104 | 104 |
/** |
... | ... | |
170 | 170 |
$this->assertNoText(t('There was a problem with your form submission.'), 'Honeypot not blocking node form previews.'); |
171 | 171 |
} |
172 | 172 |
} |
173 |
|
|
174 |
/** |
|
175 |
* Test the functionality of the Honeypot module's integration with Trigger. |
|
176 |
*/ |
|
177 |
class HoneypotTriggerTestCase extends DrupalWebTestCase { |
|
178 |
public static function getInfo() { |
|
179 |
return array( |
|
180 |
'name' => 'Honeypot Trigger integration', |
|
181 |
'description' => 'Ensure that Honeypot triggers events correctly.', |
|
182 |
'group' => 'Form API', |
|
183 |
); |
|
184 |
} |
|
185 |
|
|
186 |
public function setUp() { |
|
187 |
// Enable modules required for this test. |
|
188 |
parent::setUp(array('honeypot', 'trigger')); |
|
189 |
|
|
190 |
// Set up required Honeypot variables. |
|
191 |
variable_set('honeypot_element_name', 'url'); |
|
192 |
// Disable time_limit protection. |
|
193 |
variable_set('honeypot_time_limit', 0); |
|
194 |
// Test protecting all forms. |
|
195 |
variable_set('honeypot_protect_all_forms', TRUE); |
|
196 |
variable_set('honeypot_log', FALSE); |
|
197 |
|
|
198 |
// Set up other required variables. |
|
199 |
variable_set('user_email_verification', TRUE); |
|
200 |
variable_set('user_register', USER_REGISTER_VISITORS); |
|
201 |
|
|
202 |
// Assign new action to Honeypot form rejection Trigger. |
|
203 |
db_insert('trigger_assignments') |
|
204 |
->fields(array( |
|
205 |
'hook' => 'honeypot_reject', |
|
206 |
'aid' => 'system_block_ip_action', |
|
207 |
'weight' => 1, |
|
208 |
)) |
|
209 |
->execute(); |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* Test trigger integration. |
|
214 |
*/ |
|
215 |
public function testHoneypotTriggerIntegration() { |
|
216 |
// Set up form and submit it. |
|
217 |
$edit['name'] = $this->randomName(); |
|
218 |
$edit['mail'] = $edit['name'] . '@example.com'; |
|
219 |
$edit['url'] = 'http://www.example.com/'; |
|
220 |
$this->drupalPost('user/register', $edit, t('Create new account')); |
|
221 |
|
|
222 |
// Make sure Honeypot is working. |
|
223 |
$this->assertText(t('There was a problem with your form submission.'), 'Honeypot working correctly.'); |
|
224 |
|
|
225 |
// Visit the home page and make sure the user is banned. |
|
226 |
$this->drupalGet('node'); |
|
227 |
$this->assertText(t('has been banned'), 'User banned successfully.'); |
|
228 |
} |
|
229 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules