diff --git a/e107_plugins/faqs/faqs_shortcodes.php b/e107_plugins/faqs/faqs_shortcodes.php
index 117c1e333..7cad4ce26 100644
--- a/e107_plugins/faqs/faqs_shortcodes.php
+++ b/e107_plugins/faqs/faqs_shortcodes.php
@@ -283,7 +283,7 @@ class faqs_shortcodes extends e_shortcode
return "(".($this->counter -1).")";
}
- return isset($this->var['f_count']) ? $this->var['f_count'] : 0;
+ return isset($this->var['f_count']) ? $this->var['f_count'] : '';
}
function sc_faq_cat_diz()
diff --git a/e107_tests/tests/unit/e_parse_shortcodeTest.php b/e107_tests/tests/unit/e_parse_shortcodeTest.php
index 5a738ce3a..6761ba5f2 100644
--- a/e107_tests/tests/unit/e_parse_shortcodeTest.php
+++ b/e107_tests/tests/unit/e_parse_shortcodeTest.php
@@ -1024,6 +1024,60 @@ class e_parse_shortcodeTest extends \Codeception\Test\Unit
}
+ /**
+ * @see https://github.com/e107inc/e107/issues/4512
+ * @throws Exception
+ */
+ public function testFaqShortcodesDisplayFaqTotal()
+ {
+ require_once(e_PLUGIN."faqs/faqs_shortcodes.php");
+
+ /** @var faqs_shortcodes $sc */
+ $sc = $this->make('faqs_shortcodes');
+
+ $faqsConfig = e107::getPlugConfig("faqs");
+ $beforePref = $faqsConfig->getPref("display_total");
+ try
+ {
+ $faqsConfig->setPref("display_total", true);
+ $sc->counter = $counter = 593407;
+
+ $output = e107::getParser()->parseTemplate("{FAQ_COUNT}", true, $sc);
+ $this->assertEquals("(".($counter-1).")", $output);
+ }
+ finally
+ {
+ $faqsConfig->setPref("display_total", $beforePref);
+ }
+ }
+
+ /**
+ * @see https://github.com/e107inc/e107/issues/4512
+ * @throws Exception
+ */
+ public function testFaqShortcodesDoNotDisplayFaqTotal()
+ {
+ require_once(e_PLUGIN . "faqs/faqs_shortcodes.php");
+
+ /** @var faqs_shortcodes $sc */
+ $sc = $this->make('faqs_shortcodes');
+
+ $faqsConfig = e107::getPlugConfig("faqs");
+ $beforePref = $faqsConfig->getPref("display_total");
+ try
+ {
+ $faqsConfig->setPref("display_total", false);
+ $sc->counter = 1017703;
+
+ $output = e107::getParser()->parseTemplate("{FAQ_COUNT}", true, $sc);
+ $this->assertEquals("", $output);
+ }
+ finally
+ {
+ $faqsConfig->setPref("display_total", $beforePref);
+ }
+ }
+
public function testFpwShortcodes()
{
require_once(e_CORE."shortcodes/batch/fpw_shortcodes.php");