From f1ac3d0f748b8d4c734bc5259fd73c8338a17735 Mon Sep 17 00:00:00 2001 From: liugang Date: Sat, 13 Sep 2025 13:09:22 +0800 Subject: [PATCH] + [misc] Add unit tests for branchZen::setParamsForLink() 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 --- .../branch/test/lib/branch.unittest.class.php | 20 +++++++++++++ module/branch/test/zen/setparamsforlink.php | 29 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100755 module/branch/test/zen/setparamsforlink.php diff --git a/module/branch/test/lib/branch.unittest.class.php b/module/branch/test/lib/branch.unittest.class.php index f866498136..4fd8fb5b88 100644 --- a/module/branch/test/lib/branch.unittest.class.php +++ b/module/branch/test/lib/branch.unittest.class.php @@ -5,6 +5,7 @@ class branchTest { global $tester; $this->objectModel = $tester->loadModel('branch'); + $this->objectZen = $tester->loadZen('branch'); } /** @@ -476,4 +477,23 @@ class branchTest return $result; } + + /** + * Test setParamsForLink method. + * + * @param string $module + * @param string $link + * @param int $projectID + * @param int $productID + * @access public + * @return string + */ + public function setParamsForLinkTest(string $module, string $link, int $projectID, int $productID): string + { + $result = $this->objectZen->setParamsForLink($module, $link, $projectID, $productID); + + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/branch/test/zen/setparamsforlink.php b/module/branch/test/zen/setparamsforlink.php new file mode 100755 index 0000000000..a7bc66005f --- /dev/null +++ b/module/branch/test/zen/setparamsforlink.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +getMethod('setParamsForLink'); + +r($func->invokeArgs($zen->newInstance(), ['plan', '/test-%d-%d-%s', 1, 2])) && p() && e('/test-1-2-{id}'); +r($func->invokeArgs($zen->newInstance(), ['program', '/test-%d-%d-%s', 1, 2])) && p() && e('/test-1-2-{id}'); +r($func->invokeArgs($zen->newInstance(), ['project', '/test-%d-%s', 1, 2])) && p() && e('/test-2-{id}'); +r($func->invokeArgs($zen->newInstance(), ['', '/test-%d-%d-%s', 1, 2])) && p() && e('/test-1-2-{id}'); +r($func->invokeArgs($zen->newInstance(), ['story', '/test-%d-%s', 1, 2])) && p() && e('/test-2-{id}'); \ No newline at end of file