+ [misc] Add unit tests for taskZen::getAssignedToOptions() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
|
||||
require_once dirname(__FILE__, 5) . '/test/lib/test.class.php';
|
||||
|
||||
class taskZenTest extends baseTest
|
||||
{
|
||||
protected $moduleName = 'task';
|
||||
protected $className = 'zen';
|
||||
|
||||
/**
|
||||
* Test getAssignedToOptions method.
|
||||
*
|
||||
* @param string $manageLink
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getAssignedToOptionsTest(string $manageLink): array
|
||||
{
|
||||
$result = $this->invokeArgs('getAssignedToOptions', [$manageLink]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
// Convert toolbar arrays to count for easier testing
|
||||
if(isset($result['single']['toolbar']) && is_array($result['single']['toolbar']))
|
||||
{
|
||||
$result['single']['toolbarCount'] = count($result['single']['toolbar']);
|
||||
}
|
||||
if(isset($result['multiple']['toolbar']) && is_array($result['multiple']['toolbar']))
|
||||
{
|
||||
$result['multiple']['toolbarCount'] = count($result['multiple']['toolbar']);
|
||||
// Extract first toolbar key for testing
|
||||
if(isset($result['multiple']['toolbar'][0]['key']))
|
||||
{
|
||||
$result['multiple']['firstToolbarKey'] = $result['multiple']['toolbar'][0]['key'];
|
||||
}
|
||||
if(isset($result['multiple']['toolbar'][1]['key']))
|
||||
{
|
||||
$result['multiple']['secondToolbarKey'] = $result['multiple']['toolbar'][1]['key'];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 taskZen::getAssignedToOptions();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 步骤1:空manageLink-multiple模式multiple为true第multiple条的multiple属性 @1
|
||||
- 步骤2:空manageLink-multiple模式checkbox为true第multiple条的checkbox属性 @1
|
||||
- 步骤3:空manageLink-multiple模式第一个工具栏按钮为selectAll第multiple条的firstToolbarKey属性 @selectAll
|
||||
- 步骤4:空manageLink-multiple模式第二个工具栏按钮为cancelSelect第multiple条的secondToolbarKey属性 @cancelSelect
|
||||
- 步骤5:带manageLink时single包含1个工具栏按钮第single条的toolbarCount属性 @1
|
||||
|
||||
*/
|
||||
|
||||
// 1. 导入依赖(路径固定,不可修改)
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/zen.class.php';
|
||||
|
||||
// 2. 用户登录
|
||||
su('admin');
|
||||
|
||||
// 3. 创建测试实例(变量名与模块名一致)
|
||||
$taskTest = new taskZenTest();
|
||||
|
||||
// 4. 执行测试步骤(必须至少5个)
|
||||
r($taskTest->getAssignedToOptionsTest('')) && p('multiple:multiple') && e('1'); // 步骤1:空manageLink-multiple模式multiple为true
|
||||
r($taskTest->getAssignedToOptionsTest('')) && p('multiple:checkbox') && e('1'); // 步骤2:空manageLink-multiple模式checkbox为true
|
||||
r($taskTest->getAssignedToOptionsTest('')) && p('multiple:firstToolbarKey') && e('selectAll'); // 步骤3:空manageLink-multiple模式第一个工具栏按钮为selectAll
|
||||
r($taskTest->getAssignedToOptionsTest('')) && p('multiple:secondToolbarKey') && e('cancelSelect'); // 步骤4:空manageLink-multiple模式第二个工具栏按钮为cancelSelect
|
||||
r($taskTest->getAssignedToOptionsTest('http://test.com/manage')) && p('single:toolbarCount') && e('1'); // 步骤5:带manageLink时single包含1个工具栏按钮
|
||||
Reference in New Issue
Block a user