From 1a2fa5273f114876accc3970fead84d55fbb0229 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Fri, 20 Sep 2019 00:44:01 -0700 Subject: [PATCH] Added isTest property. --- .../kotlin/net/thauvin/erik/akismet/Akismet.kt | 17 +++++++++++------ .../net/thauvin/erik/akismet/AkismetTest.kt | 10 +++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt b/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt index 5706d90..f5358b4 100644 --- a/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt +++ b/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt @@ -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 = 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 = 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 = 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 = 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 = 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 = emptyMap() ): Boolean { diff --git a/src/test/kotlin/net/thauvin/erik/akismet/AkismetTest.kt b/src/test/kotlin/net/thauvin/erik/akismet/AkismetTest.kt index b1a074e..5b1a5a9 100644 --- a/src/test/kotlin/net/thauvin/erik/akismet/AkismetTest.kt +++ b/src/test/kotlin/net/thauvin/erik/akismet/AkismetTest.kt @@ -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