+ [misc] Add unit tests for convertTao::processWorkflowHooks() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,14 @@ declare(strict_types = 1);
|
||||
|
||||
require_once dirname(__FILE__, 5) . '/test/lib/test.class.php';
|
||||
|
||||
class MockWorkflowHook
|
||||
{
|
||||
public function check($hook)
|
||||
{
|
||||
return array('SELECT * FROM zt_bug', array());
|
||||
}
|
||||
}
|
||||
|
||||
class convertTaoTest extends baseTest
|
||||
{
|
||||
protected $moduleName = 'convert';
|
||||
@@ -36,4 +44,38 @@ class convertTaoTest extends baseTest
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processWorkflowHooks method.
|
||||
*
|
||||
* @param array $jiraAction
|
||||
* @param array $jiraStepList
|
||||
* @param string $module
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function processWorkflowHooksTest($jiraAction = array(), $jiraStepList = array(), $module = '')
|
||||
{
|
||||
global $app;
|
||||
|
||||
$convertTaoFile = $app->getAppRoot() . 'module/convert/tao.php';
|
||||
if(file_exists($convertTaoFile))
|
||||
{
|
||||
include_once $convertTaoFile;
|
||||
$convertTao = new convertTao();
|
||||
|
||||
// Mock workflowhook对象
|
||||
$convertTao->workflowhook = new MockWorkflowHook();
|
||||
|
||||
$reflection = new ReflectionClass($convertTao);
|
||||
$method = $reflection->getMethod('processWorkflowHooks');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invokeArgs($convertTao, array($jiraAction, $jiraStepList, $module));
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 convertTao::processWorkflowHooks();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行convertTest模块的processWorkflowHooksTest方法,参数是array @0
|
||||
- 执行convertTest模块的processWorkflowHooksTest方法,参数是array @0
|
||||
- 执行convertTest模块的processWorkflowHooksTest方法,参数是array
|
||||
- 第0条的action属性 @update
|
||||
- 第0条的table属性 @bug
|
||||
- 第0条的conditionType属性 @data
|
||||
- 执行convertTest模块的processWorkflowHooksTest方法,参数是array
|
||||
- 第0条的action属性 @update
|
||||
- 第0条的table属性 @story
|
||||
- 执行convertTest模块的processWorkflowHooksTest方法,参数是array
|
||||
- 第0条的action属性 @update
|
||||
- 第0条的table属性 @task
|
||||
- 第0条的conditionType属性 @data
|
||||
- 第0条的sqlResult属性 @empty
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/tao.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$convertTest = new convertTaoTest();
|
||||
|
||||
r($convertTest->processWorkflowHooksTest(array(), array(), 'bug')) && p() && e('0');
|
||||
r($convertTest->processWorkflowHooksTest(array('results' => array()), array(), 'bug')) && p() && e('0');
|
||||
r($convertTest->processWorkflowHooksTest(array('results' => array('unconditional-result' => array('@attributes' => array('step' => '1')))), array('1' => 'open'), 'bug')) && p('0:action,table,conditionType') && e('update,bug,data');
|
||||
r($convertTest->processWorkflowHooksTest(array('results' => array('unconditional-result' => array('@attributes' => array('step' => '2')))), array('2' => array('resolved', 'closed')), 'story')) && p('0:action,table') && e('update,story');
|
||||
r($convertTest->processWorkflowHooksTest(array('results' => array('unconditional-result' => array('@attributes' => array('step' => '3')))), array('3' => 'doing'), 'task')) && p('0:action,table,conditionType,sqlResult') && e('update,task,data,empty');
|
||||
Reference in New Issue
Block a user