From 98c2148f93c0ee5b4aaf8c5e1b79d19f2fb8be99 Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 11 Nov 2025 14:11:05 +0800 Subject: [PATCH] + [misc] Add unit test script for repoZen::checkSyncResult() 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/repo/test/zen/checksyncresult.php | 67 ++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 module/repo/test/zen/checksyncresult.php diff --git a/module/repo/test/zen/checksyncresult.php b/module/repo/test/zen/checksyncresult.php new file mode 100755 index 0000000000..e3f2245c80 --- /dev/null +++ b/module/repo/test/zen/checksyncresult.php @@ -0,0 +1,67 @@ +#!/usr/bin/env php +id = 101; +$repo1->SCM = 'Git'; +$repo1->synced = 0; +$repo1->commits = 0; + +$repo2 = new stdClass(); +$repo2->id = 102; +$repo2->SCM = 'Gitlab'; +$repo2->synced = 0; +$repo2->commits = 0; + +$repo3 = new stdClass(); +$repo3->id = 103; +$repo3->SCM = 'Subversion'; +$repo3->synced = 0; +$repo3->commits = 0; + +$repo4 = new stdClass(); +$repo4->id = 104; +$repo4->SCM = 'Git'; +$repo4->synced = 1; +$repo4->commits = 100; + +$branches1 = array('develop', 'feature/test'); +$branches2 = array(); + +r($repoTest->checkSyncResultTest($repo1, $branches1, 'master', 10, 'batch')) && p() && e('10'); // 测试步骤1:Git类型仓库,有提交数量,batch类型 +r($repoTest->checkSyncResultTest($repo1, $branches1, 'master', 5, 'sync')) && p() && e('finish'); // 测试步骤2:Git类型仓库,有提交数量,sync类型 +r($repoTest->checkSyncResultTest($repo1, $branches1, 'master', 0, 'sync')) && p() && e('finish'); // 测试步骤3:Git类型仓库,无提交,未同步,有剩余分支 +r($repoTest->checkSyncResultTest($repo1, $branches2, '', 0, 'sync')) && p() && e('finish'); // 测试步骤4:Git类型仓库,无提交,未同步,无剩余分支 +r($repoTest->checkSyncResultTest($repo2, $branches2, '', 0, 'sync')) && p() && e('finish'); // 测试步骤5:Gitlab类型仓库,无提交,未同步 +r($repoTest->checkSyncResultTest($repo3, array(), '', 20, 'batch')) && p() && e('20'); // 测试步骤6:Subversion类型仓库,有提交数量,batch类型 +r($repoTest->checkSyncResultTest($repo4, array(), '', 15, 'batch')) && p() && e('15'); // 测试步骤7:Git类型仓库,已同步,有提交数量 +r($repoTest->checkSyncResultTest(null, array(), '', 0, 'batch')) && p() && e('0'); // 测试步骤8:无效的repo对象参数 +r($repoTest->checkSyncResultTest($repo1, array(), '', 10, 'invalid')) && p() && e('0'); // 测试步骤9:无效的type参数 +r($repoTest->checkSyncResultTest($repo1, array(), '', 0, 'sync')) && p() && e('finish'); // 测试步骤10:Git类型仓库,无提交,未同步,当前分支为空 \ No newline at end of file