diff --git a/module/convert/test/lib/tao.class.php b/module/convert/test/lib/tao.class.php index 9f18c0e80e..2f8334d973 100644 --- a/module/convert/test/lib/tao.class.php +++ b/module/convert/test/lib/tao.class.php @@ -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(); + } } diff --git a/module/convert/test/tao/processworkflowhooks.php b/module/convert/test/tao/processworkflowhooks.php new file mode 100755 index 0000000000..ff90bb40b8 --- /dev/null +++ b/module/convert/test/tao/processworkflowhooks.php @@ -0,0 +1,38 @@ +#!/usr/bin/env php +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'); \ No newline at end of file