Added isTest property.

This commit is contained in:
Erik C. Thauvin 2019-09-20 00:44:01 -07:00
parent a7f6b6a6c4
commit 1a2fa5273f
2 changed files with 16 additions and 11 deletions

View file

@ -89,6 +89,11 @@ open class Akismet(apiKey: String) {
field = value
}
/**
* Set the test parameter globally. Can be overwritten in [checkComment], [submitHam] and [submitSpam].
*/
var isTest: Boolean = false
/**
* Check if the API Key has been verified.
*/
@ -183,7 +188,7 @@ open class Akismet(apiKey: String) {
blogLang: String = "",
blogCharset: String = "",
userRole: String = "",
isTest: Boolean = false,
isTest: Boolean = this.isTest,
recheckReason: String = "",
other: Map<String, String> = emptyMap()
): Boolean {
@ -226,7 +231,7 @@ open class Akismet(apiKey: String) {
blogLang: String = "",
blogCharset: String = "",
userRole: String = "",
isTest: Boolean = false,
isTest: Boolean = this.isTest,
recheckReason: String = "",
other: Map<String, String> = emptyMap()
): Boolean {
@ -274,7 +279,7 @@ open class Akismet(apiKey: String) {
blogLang: String = "",
blogCharset: String = "",
userRole: String = "",
isTest: Boolean = false,
isTest: Boolean = this.isTest,
recheckReason: String = "",
other: Map<String, String> = emptyMap()
): Boolean {
@ -318,7 +323,7 @@ open class Akismet(apiKey: String) {
blogLang: String = "",
blogCharset: String = "",
userRole: String = "",
isTest: Boolean = false,
isTest: Boolean = this.isTest,
recheckReason: String = "",
other: Map<String, String> = emptyMap()
): Boolean {
@ -363,7 +368,7 @@ open class Akismet(apiKey: String) {
blogLang: String = "",
blogCharset: String = "",
userRole: String = "",
isTest: Boolean = false,
isTest: Boolean = this.isTest,
recheckReason: String = "",
other: Map<String, String> = emptyMap()
): Boolean {
@ -407,7 +412,7 @@ open class Akismet(apiKey: String) {
blogLang: String = "",
blogCharset: String = "",
userRole: String = "",
isTest: Boolean = false,
isTest: Boolean = this.isTest,
recheckReason: String = "",
other: Map<String, String> = emptyMap()
): Boolean {

View file

@ -79,7 +79,7 @@ class AkismetTest {
private val userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6"
private val referrer = "http://www.google.com"
private val permalink = "http://yourblogdomainname.com/blog/post=1"
private val type = "comment"
private val type = Akismet.COMMENT_TYPE_COMMENT
private val author = "admin"
private val authorEmail = "test@test.com"
private val authorUrl = "http://www.CheckOutMyCoolSite.com"
@ -146,6 +146,8 @@ class AkismetTest {
userRole = Akismet.ADMIN_ROLE,
isTest = true), "check_comment(admin) -> false")
akismet.isTest = true
assertTrue(
akismet.checkComment(
userIp = userIp,
@ -156,8 +158,7 @@ class AkismetTest {
author = spamAuthor,
authorEmail = spamEmail,
authorUrl = authorUrl,
content = content,
isTest = true), "check_comment -> true")
content = content), "check_comment -> true")
assertTrue(
akismet.checkComment(
@ -167,8 +168,7 @@ class AkismetTest {
author = spamAuthor,
authorEmail = spamEmail,
authorUrl = authorUrl,
content = content,
isTest = true), "check_comment(request) -> true")
content = content), "check_comment(request) -> true")
}
@Test