protected function BotchaBaseWebTestCase::assertCommentFormSubmission in BOTCHA Spam Prevention 7.3
Same name and namespace in other branches
- 6.2 botcha.test \BotchaBaseWebTestCase::assertCommentFormSubmission()
- 6.3 tests/botcha.simpletest.test \BotchaBaseWebTestCase::assertCommentFormSubmission()
- 7.2 botcha.test \BotchaBaseWebTestCase::assertCommentFormSubmission()
Assert function for testing if comment posting works as it should.
Creates node with comment writing enabled, tries to post comment with given BOTCHA response (caller should enable the desired challenge on page node comment forms) and checks if the result is as expected.
Parameters
$node existing node to post comments to (if NULL, will be created):
$should_pass boolean describing if the posting should pass or should be blocked:
$message message to prefix to nested asserts:
$button name of button to click (t('Save') by default):
1 call to BotchaBaseWebTestCase::assertCommentFormSubmission()
- BotchaBaseWebTestCase::assertFormSubmission in tests/
botcha.simpletest.test - Check whether our suspections are real.
File
- tests/
botcha.simpletest.test, line 624 - Simpletest-tests for BOTCHA module.
Class
- BotchaBaseWebTestCase
- Base class for BOTCHA tests.
Code
protected function assertCommentFormSubmission($edit, $should_pass, $button) {
// Assertion itself.
switch ($should_pass) {
case FALSE:
// Check for error message.
$this
->assertText(BOTCHA_WRONG_RESPONSE_ERROR_MESSAGE, 'Comment submission should be blocked.', 'BOTCHA');
// Check that there is still BOTCHA after failed submit.
$this
->assertBotchaPresence(TRUE);
$this
->assertNoText($edit['subject'], 'Comment should not show up on node page.', 'BOTCHA');
// !!? Do we need to check message body?
//$this->assertNoText($comment_body, $message . ' Comment should not show up on node page.', 'BOTCHA');
break;
case TRUE:
default:
switch ($button) {
case t('Preview'):
// Check that there is still BOTCHA after preview.
$this
->assertBotchaPresence(TRUE);
break;
case t('Save'):
default:
// There should be no error message.
$this
->assertBotchaResponseAccepted();
$this
->assertText($edit['subject'], 'Comment should show up on node page.', 'BOTCHA');
// !!? Do we need to check message body?
//$this->assertText($edit['comment_body'], $message . ' Comment should show up on node page.', 'BOTCHA');
break;
}
break;
}
}