From 2e64ae56a7e756973d8cc40f2b619542cf4a0e4c Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 11 Nov 2025 00:49:25 +0800 Subject: [PATCH] + [misc] Add unit tests for productZen::getBackLink4Create() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- module/product/test/lib/zen.class.php | 14 +++++++++ .../product/test/zen/getbacklink4create.php | 29 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 module/product/test/zen/getbacklink4create.php diff --git a/module/product/test/lib/zen.class.php b/module/product/test/lib/zen.class.php index ccf8bc9cae..17a365f45d 100644 --- a/module/product/test/lib/zen.class.php +++ b/module/product/test/lib/zen.class.php @@ -329,4 +329,18 @@ class productZenTest extends baseTest return $result; } + + /** + * Test getBackLink4Create method. + * + * @param string $extra + * @access public + * @return string + */ + public function getBackLink4CreateTest(string $extra = '') + { + $result = $this->invokeArgs('getBackLink4Create', array($extra)); + if(dao::isError()) return dao::getError(); + return $result; + } } diff --git a/module/product/test/zen/getbacklink4create.php b/module/product/test/zen/getbacklink4create.php new file mode 100755 index 0000000000..ab580d167b --- /dev/null +++ b/module/product/test/zen/getbacklink4create.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +getBackLink4CreateTest('')) && p() && e('0'); // 测试步骤1:extra参数为空字符串 +r(strpos($productTest->getBackLink4CreateTest('from=qa'), 'm=qa&f=index') !== false) && p() && e('1'); // 测试步骤2:extra参数from=qa +r(strpos($productTest->getBackLink4CreateTest('from=global'), 'm=product&f=all') !== false) && p() && e('1'); // 测试步骤3:extra参数from=global +r($productTest->getBackLink4CreateTest('from=other')) && p() && e('0'); // 测试步骤4:extra参数from=other +r(strpos($productTest->getBackLink4CreateTest('from=qa, param=1'), 'm=qa&f=index') !== false) && p() && e('1'); // 测试步骤5:extra参数包含逗号和空格 \ No newline at end of file