* [misc] Fix unit tests for screenModel::buildComponentList() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,28 +1,45 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/screen.unittest.class.php';
|
||||
|
||||
/**
|
||||
|
||||
title=测试 screenModel->buildComponentList();
|
||||
title=测试 screenModel::buildComponentList();
|
||||
timeout=0
|
||||
cid=1
|
||||
cid=0
|
||||
|
||||
- 测试带有空元素的情况下,生成的组件列表数量是否正确。 @1
|
||||
- 执行screen模块的buildComponentListTest方法,参数是array @2
|
||||
- 执行screen模块的buildComponentListTest方法,参数是array @0
|
||||
- 执行screen模块的buildComponentListTest方法,参数是array @2
|
||||
- 执行screen模块的buildComponentListTest方法,参数是array @0
|
||||
- 执行screen模块的buildComponentListTest方法,参数是array @3
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/screen.unittest.class.php';
|
||||
|
||||
$screen = new screenTest();
|
||||
|
||||
$screenData = $tester->dao->select('*')->from(TABLE_SCREEN)->where('id')->eq(1)->fetch();
|
||||
$scheme = json_decode($screenData->scheme);
|
||||
$componentList = $scheme->componentList;
|
||||
// 准备测试数据
|
||||
$validComponent1 = new stdclass();
|
||||
$validComponent1->id = 'comp1';
|
||||
$validComponent1->chartConfig = new stdclass();
|
||||
$validComponent1->chartConfig->chartKey = 'bar';
|
||||
|
||||
r(count($componentList)) && p('') && e('44'); //测试组件列表数量是否正确。
|
||||
$validComponent2 = new stdclass();
|
||||
$validComponent2->id = 'comp2';
|
||||
$validComponent2->chartConfig = new stdclass();
|
||||
$validComponent2->chartConfig->chartKey = 'line';
|
||||
|
||||
$component = $componentList[0];
|
||||
r($component->chartConfig->chartKey) && p('') && e('group'); //测试组件类型是否正确。
|
||||
r($component->id) && p('') && e('5scfjzqsbzo000'); //测试组件id是否正确。
|
||||
r($component->isGroup) && p('') && e('1'); //测试组件是否为组。
|
||||
r(isset($component->groupList)) && p('') && e('1'); //测试组件是否为组。
|
||||
$groupComponent = new stdclass();
|
||||
$groupComponent->id = 'group1';
|
||||
$groupComponent->isGroup = 1;
|
||||
$groupComponent->groupList = array($validComponent1);
|
||||
$groupComponent->chartConfig = new stdclass();
|
||||
$groupComponent->chartConfig->chartKey = 'group';
|
||||
|
||||
r(count($screen->buildComponentListTest(array($validComponent1, $validComponent2)))) && p() && e(2);
|
||||
r(count($screen->buildComponentListTest(array()))) && p() && e(0);
|
||||
r(count($screen->buildComponentListTest(array($validComponent1, null, $validComponent2)))) && p() && e(2);
|
||||
r(count($screen->buildComponentListTest(array(null, false, '', 0)))) && p() && e(0);
|
||||
r(count($screen->buildComponentListTest(array($validComponent1, $groupComponent, $validComponent2)))) && p() && e(3);
|
||||
Reference in New Issue
Block a user