From faecc8a9b5b30eff79336f470f4f1a5d02942fb1 Mon Sep 17 00:00:00 2001 From: liugang Date: Wed, 10 Sep 2025 19:27:54 +0800 Subject: [PATCH] + [misc] Add unit tests for tutorialModel::getBranchesByProject() 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 --- .../test/lib/tutorial.unittest.class.php | 15 +++++++++ .../test/model/getbranchesbyproject.php | 33 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 module/tutorial/test/model/getbranchesbyproject.php diff --git a/module/tutorial/test/lib/tutorial.unittest.class.php b/module/tutorial/test/lib/tutorial.unittest.class.php index 321af3aa50..fea6975f50 100644 --- a/module/tutorial/test/lib/tutorial.unittest.class.php +++ b/module/tutorial/test/lib/tutorial.unittest.class.php @@ -1049,4 +1049,19 @@ class tutorialTest return $result; } + + /** + * 测试获取新手模式项目关联分支。 + * Test get branches by project. + * + * @access public + * @return array + */ + public function getBranchesByProjectTest(): array + { + $result = $this->objectModel->getBranchesByProject(); + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/tutorial/test/model/getbranchesbyproject.php b/module/tutorial/test/model/getbranchesbyproject.php new file mode 100755 index 0000000000..0ca4dc3d79 --- /dev/null +++ b/module/tutorial/test/model/getbranchesbyproject.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +getBranchesByProjectTest())) && p() && e('1'); // 步骤1:验证返回数组长度 +r(count($tutorialTest->getBranchesByProjectTest()[1])) && p() && e('1'); // 步骤2:验证产品ID为1的分支数量 +r($tutorialTest->getBranchesByProjectTest()[1][0]->project) && p() && e('2'); // 步骤3:验证第一个分支的项目ID +r($tutorialTest->getBranchesByProjectTest()[1][0]->product) && p() && e('1'); // 步骤4:验证第一个分支的产品ID +r($tutorialTest->getBranchesByProjectTest()[1][0]->branch) && p() && e('0'); // 步骤5:验证第一个分支的分支ID \ No newline at end of file