function CaptchaAdminTestCase::testCaptchaPointSettingGetterAndSetter in CAPTCHA 6.2
Same name and namespace in other branches
- 7 captcha.test \CaptchaAdminTestCase::testCaptchaPointSettingGetterAndSetter()
Test the CAPTCHA point setting getter/setter.
File
- ./
captcha.test, line 423 - Tests for CAPTCHA module.
Class
Code
function testCaptchaPointSettingGetterAndSetter() {
$comment_form_id = self::COMMENT_FORM_ID;
// Set to 'none'.
captcha_set_form_id_setting($comment_form_id, 'none');
$result = captcha_get_form_id_setting($comment_form_id);
$this
->assertNotNull($result, 'Setting and getting CAPTCHA point: none', 'CAPTCHA');
$this
->assertNull($result->module, 'Setting and getting CAPTCHA point: none', 'CAPTCHA');
$this
->assertNull($result->captcha_type, 'Setting and getting CAPTCHA point: none', 'CAPTCHA');
$result = captcha_get_form_id_setting($comment_form_id, TRUE);
$this
->assertEqual($result, 'none', 'Setting and symbolic getting CAPTCHA point: "none"', 'CAPTCHA');
// Set to 'default'
captcha_set_form_id_setting($comment_form_id, 'default');
variable_set('captcha_default_challenge', 'foo/bar');
$result = captcha_get_form_id_setting($comment_form_id);
$this
->assertNotNull($result, 'Setting and getting CAPTCHA point: default', 'CAPTCHA');
$this
->assertEqual($result->module, 'foo', 'Setting and getting CAPTCHA point: default', 'CAPTCHA');
$this
->assertEqual($result->captcha_type, 'bar', 'Setting and getting CAPTCHA point: default', 'CAPTCHA');
$result = captcha_get_form_id_setting($comment_form_id, TRUE);
$this
->assertEqual($result, 'default', 'Setting and symbolic getting CAPTCHA point: "default"', 'CAPTCHA');
// Set to 'baz/boo'.
captcha_set_form_id_setting($comment_form_id, 'baz/boo');
$result = captcha_get_form_id_setting($comment_form_id);
$this
->assertNotNull($result, 'Setting and getting CAPTCHA point: baz/boo', 'CAPTCHA');
$this
->assertEqual($result->module, 'baz', 'Setting and getting CAPTCHA point: baz/boo', 'CAPTCHA');
$this
->assertEqual($result->captcha_type, 'boo', 'Setting and getting CAPTCHA point: baz/boo', 'CAPTCHA');
$result = captcha_get_form_id_setting($comment_form_id, TRUE);
$this
->assertEqual($result, 'baz/boo', 'Setting and symbolic getting CAPTCHA point: "baz/boo"', 'CAPTCHA');
// Set to NULL (which should delete the CAPTCHA point setting entry).
captcha_set_form_id_setting($comment_form_id, NULL);
$result = captcha_get_form_id_setting($comment_form_id);
$this
->assertNull($result, 'Setting and getting CAPTCHA point: NULL', 'CAPTCHA');
$result = captcha_get_form_id_setting($comment_form_id, TRUE);
$this
->assertNull($result, 'Setting and symbolic getting CAPTCHA point: NULL', 'CAPTCHA');
// Set with object.
$captcha_type = new stdClass();
$captcha_type->module = 'baba';
$captcha_type->captcha_type = 'fofo';
captcha_set_form_id_setting($comment_form_id, $captcha_type);
$result = captcha_get_form_id_setting($comment_form_id);
$this
->assertNotNull($result, 'Setting and getting CAPTCHA point: baba/fofo', 'CAPTCHA');
$this
->assertEqual($result->module, 'baba', 'Setting and getting CAPTCHA point: baba/fofo', 'CAPTCHA');
$this
->assertEqual($result->captcha_type, 'fofo', 'Setting and getting CAPTCHA point: baba/fofo', 'CAPTCHA');
$result = captcha_get_form_id_setting($comment_form_id, TRUE);
$this
->assertEqual($result, 'baba/fofo', 'Setting and symbolic getting CAPTCHA point: "baba/fofo"', 'CAPTCHA');
}