From dfbb7f367c38b1caed71286f79acb32014086acc Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 22 Sep 2025 10:46:34 +0800 Subject: [PATCH] * [misc] Enhance unit tests for blockModel::getBlockInitStatus() 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 --- .../block/test/model/getblockinitstatus.php | 61 +++++++++---------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/module/block/test/model/getblockinitstatus.php b/module/block/test/model/getblockinitstatus.php index d8f8acef4c..c0ceb66f7c 100755 --- a/module/block/test/model/getblockinitstatus.php +++ b/module/block/test/model/getblockinitstatus.php @@ -1,46 +1,41 @@ #!/usr/bin/env php id->range('2-5'); - $block->account->range('admin'); - $block->dashboard->range('my'); - $block->module->range('welcome,guide,project,project'); - $block->code->range('welcome,guide,list,statistic'); - $block->title->prefix('区块名称')->range('1-4'); - $block->width->range('2,2,1,1'); - - $block->gen(4); -} /** -title=测试 blockModel->getBlockInitStatus(); +title=测试 blockModel::getBlockInitStatus(); timeout=0 -cid=1 +cid=0 -- 测试 my 仪表盘下返回为 1 @1 - -- 测试 product 仪表盘下返回为 0 @0 - -- 测试不存在的仪表盘返回为 0 @0 - -- 测试不传仪表盘参数返回为 0 @0 +- 执行blockTest模块的getBlockInitStatusTest方法,参数是'my' @1 +- 执行blockTest模块的getBlockInitStatusTest方法,参数是'product' @0 +- 执行blockTest模块的getBlockInitStatusTest方法,参数是'' @0 +- 执行blockTest模块的getBlockInitStatusTest方法,参数是'nonexistent_dashboard' @0 +- 执行blockTest模块的getBlockInitStatusTest方法,参数是'project' @0 +- 执行blockTest模块的getBlockInitStatusTest方法,参数是'my' @1 +- 执行blockTest模块的getBlockInitStatusTest方法,参数是'my' @0 */ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/block.unittest.class.php'; + +su('admin'); + global $tester; -$tester->loadModel('block'); - -initData(); $tester->loadModel('setting')->setItem("admin.my.common.blockInited@rnd", '1'); -$tester->loadModel('setting')->setItem("admin.my.block.initVersion", 'rnd'); +$tester->loadModel('setting')->setItem("user1.my.common.blockInited@rnd", '1'); -r($tester->block->getBlockInitStatus('my')) && p('') && e('1'); // 测试 my 仪表盘下返回为 1 -r($tester->block->getBlockInitStatus('product')) && p('') && e('0'); // 测试 product 仪表盘下返回为 0 -r($tester->block->getBlockInitStatus('asda??')) && p('') && e('0'); // 测试不存在的仪表盘返回为 0 -r($tester->block->getBlockInitStatus('')) && p('') && e('0'); // 测试不传仪表盘参数返回为 0 +$blockTest = new blockTest(); + +r($blockTest->getBlockInitStatusTest('my')) && p('') && e('1'); +r($blockTest->getBlockInitStatusTest('product')) && p('') && e('0'); +r($blockTest->getBlockInitStatusTest('')) && p('') && e('0'); +r($blockTest->getBlockInitStatusTest('nonexistent_dashboard')) && p('') && e('0'); +r($blockTest->getBlockInitStatusTest('project')) && p('') && e('0'); + +su('user1'); +r($blockTest->getBlockInitStatusTest('my')) && p('') && e('1'); + +su('user2'); +r($blockTest->getBlockInitStatusTest('my')) && p('') && e('0'); \ No newline at end of file