* [misc] Enhance unit tests for blockModel::getBlockInitStatus() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-25 09:16:03 +08:00
co-authored by Claude
parent 813986390a
commit dfbb7f367c
+28 -33
View File
@@ -1,46 +1,41 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
su('admin');
function initData()
{
$block = zenData('block');
$block->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');