+ [misc] Add unit tests for pivotZen::workload() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -240,4 +240,33 @@ class pivotZenTest extends baseTest
|
||||
'configs' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test workload method.
|
||||
*
|
||||
* @param string $begin
|
||||
* @param string $end
|
||||
* @param int $days
|
||||
* @param float $workhour
|
||||
* @param int $dept
|
||||
* @param string $assign
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function workloadTest(string $begin = '', string $end = '', int $days = 0, float $workhour = 0, int $dept = 0, string $assign = 'assign')
|
||||
{
|
||||
$this->invokeArgs('workload', [$begin, $end, $days, $workhour, $dept, $assign]);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return array(
|
||||
'workload' => $this->instance->view->workload ?? array(),
|
||||
'begin' => $this->instance->view->begin ?? '',
|
||||
'end' => $this->instance->view->end ?? '',
|
||||
'days' => $this->instance->view->days ?? 0,
|
||||
'workhour' => $this->instance->view->workhour ?? 0,
|
||||
'dept' => $this->instance->view->dept ?? 0,
|
||||
'assign' => $this->instance->view->assign ?? '',
|
||||
'title' => $this->instance->view->title ?? ''
|
||||
);
|
||||
}
|
||||
}
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 pivotZen::workload();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行pivotTest模块的workloadTest方法,参数是'', '', 0, 0, 0, 'assign'
|
||||
- 属性assign @assign
|
||||
- 属性workhour @7.0
|
||||
- 执行pivotTest模块的workloadTest方法,参数是'2025-10-01', '2025-10-31', 0, 0, 0, 'assign'
|
||||
- 属性begin @2025-10-01
|
||||
- 属性end @2025-10-31
|
||||
- 执行pivotTest模块的workloadTest方法,参数是'2025-11-01', '2025-11-15', 10, 8, 0, 'assign'
|
||||
- 属性days @10
|
||||
- 属性workhour @8
|
||||
- 执行pivotTest模块的workloadTest方法,参数是'', '', 0, 0, 1, 'assign'
|
||||
- 属性dept @1
|
||||
- 属性assign @assign
|
||||
- 执行pivotTest模块的workloadTest方法,参数是'', '', 0, 0, 0, 'finishedBy' 属性assign @finishedBy
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/pivotzen.unittest.class.php';
|
||||
|
||||
zenData('user')->gen(10);
|
||||
zenData('dept')->gen(5);
|
||||
zenData('task')->gen(20);
|
||||
|
||||
su('admin');
|
||||
|
||||
$pivotTest = new pivotZenTest();
|
||||
|
||||
r($pivotTest->workloadTest('', '', 0, 0, 0, 'assign')) && p('assign,workhour') && e('assign,7.0');
|
||||
r($pivotTest->workloadTest('2025-10-01', '2025-10-31', 0, 0, 0, 'assign')) && p('begin,end') && e('2025-10-01,2025-10-31');
|
||||
r($pivotTest->workloadTest('2025-11-01', '2025-11-15', 10, 8, 0, 'assign')) && p('days,workhour') && e('10,8');
|
||||
r($pivotTest->workloadTest('', '', 0, 0, 1, 'assign')) && p('dept,assign') && e('1,assign');
|
||||
r($pivotTest->workloadTest('', '', 0, 0, 0, 'finishedBy')) && p('assign') && e('finishedBy');
|
||||
Reference in New Issue
Block a user