function BotchaAdminTestCase::testBotchaPointSettingGetterAndSetter in BOTCHA Spam Prevention 6
Same name and namespace in other branches
- 7 botcha.test \BotchaAdminTestCase::testBotchaPointSettingGetterAndSetter()
Test the BOTCHA point setting getter/setter.
File
- ./
botcha.test, line 505 - Tests for BOTCHA module.
Class
Code
function testBotchaPointSettingGetterAndSetter() {
$comment_form_id = self::COMMENT_FORM_ID;
// Set to 'none'.
botcha_set_form_id_setting($comment_form_id, 'none');
$result = botcha_get_form_id_setting($comment_form_id);
$this
->assertNotNull($result, 'Setting and getting BOTCHA point: none', 'BOTCHA');
$this
->assertNull($result->botcha_type, 'Setting and getting BOTCHA point: none', 'BOTCHA');
$result = botcha_get_form_id_setting($comment_form_id, TRUE);
$this
->assertEqual($result, 'none', 'Setting and symbolic getting BOTCHA point: "none"', 'BOTCHA');
// Set to 'default'
botcha_set_form_id_setting($comment_form_id, 'default');
$result = botcha_get_form_id_setting($comment_form_id);
$this
->assertNotNull($result, 'Setting and getting BOTCHA point: default', 'BOTCHA');
$this
->assertEqual($result->botcha_type, 'default', 'Setting and getting BOTCHA point: default', 'BOTCHA');
$result = botcha_get_form_id_setting($comment_form_id, TRUE);
$this
->assertEqual($result, 'default', 'Setting and symbolic getting BOTCHA point: "default"', 'BOTCHA');
// Set to 'boo'.
botcha_set_form_id_setting($comment_form_id, 'boo');
$result = botcha_get_form_id_setting($comment_form_id);
$this
->assertNotNull($result, 'Setting and getting BOTCHA point: boo', 'BOTCHA');
$this
->assertEqual($result->botcha_type, 'boo', 'Setting and getting BOTCHA point: boo', 'BOTCHA');
$result = botcha_get_form_id_setting($comment_form_id, TRUE);
$this
->assertEqual($result, 'boo', 'Setting and symbolic getting BOTCHA point: "boo"', 'BOTCHA');
// Set to NULL (which should delete the BOTCHA point setting entry).
botcha_set_form_id_setting($comment_form_id, NULL);
$result = botcha_get_form_id_setting($comment_form_id);
$this
->assertNull($result, 'Setting and getting BOTCHA point: NULL', 'BOTCHA');
$result = botcha_get_form_id_setting($comment_form_id, TRUE);
$this
->assertNull($result, 'Setting and symbolic getting BOTCHA point: NULL', 'BOTCHA');
// // Set with object.
// $botcha_type = new stdClass;
// $botcha_type->botcha_type = 'fofo';
// botcha_set_form_id_setting($comment_form_id, $botcha_type);
// $result = botcha_get_form_id_setting($comment_form_id);
// $this->assertNotNull($result, 'Setting and getting BOTCHA point: fofo', 'BOTCHA');
// $this->assertEqual($result->botcha_type, 'fofo', 'Setting and getting BOTCHA point: fofo', 'BOTCHA');
// $result = botcha_get_form_id_setting($comment_form_id, TRUE);
// $this->assertEqual($result, 'fofo', 'Setting and symbolic getting BOTCHA point: "fofo"', 'BOTCHA');
}