* Add unit test for actionModel::updateStageAttribute.
This commit is contained in:
@@ -1671,13 +1671,15 @@ class actionModel extends model
|
||||
* Update stage attribute.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param array $idList
|
||||
* @param array $executions
|
||||
* @access public
|
||||
* @return int
|
||||
* @return bool
|
||||
*/
|
||||
public function updateStageAttribute(string $attribute, array $stages): int
|
||||
public function updateStageAttribute(string $attribute, array $executions): bool
|
||||
{
|
||||
return $this->dao->update(TABLE_EXECUTION)->set('attribute')->eq($attribute)->where('id')->in($stages)->exec();
|
||||
$this->dao->update(TABLE_EXECUTION)->set('attribute')->eq($attribute)->where('id')->in($executions)->exec();
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -658,4 +658,24 @@ class actionTest
|
||||
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试更新阶段的属性。
|
||||
* Test update stage attribute.
|
||||
*
|
||||
* @param string $attributeList
|
||||
* @param array $executionID
|
||||
* @access public
|
||||
* @return array|bool
|
||||
*/
|
||||
public function updateStageAttributeTest(string $attribute, array $stages): array|bool
|
||||
{
|
||||
$this->objectModel->updateStageAttribute($attribute, $stages);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
global $tester;
|
||||
$objects = $tester->dao->select('*')->from(TABLE_EXECUTION)->where('id')->in($stages)->fetchAll();
|
||||
return $objects;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/action.class.php';
|
||||
su('admin');
|
||||
|
||||
zdTable('project')->gen(5);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 actionModel->read();
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试attributeList为0,executionID为0 >> 0
|
||||
测试attributeList为1,executionID为1 >> 1
|
||||
测试attributeList为attribute,executionID为2 >> 3,attribute;4,attribute
|
||||
|
||||
*/
|
||||
|
||||
$attributeList = array(0, 1, 'attribute');
|
||||
$executionID = array(array(1), array(2), array(3, 4));
|
||||
|
||||
$action = new actionTest();
|
||||
|
||||
r($action->updateStageAttributeTest($attributeList[0], $executionID[0])) && p('0:id,attribute') && e('1,0'); //测试attributeList为0,executionID为0
|
||||
r($action->updateStageAttributeTest($attributeList[1], $executionID[1])) && p('0:id,attribute') && e('2,1'); //测试attributeList为1,executionID为1
|
||||
r($action->updateStageAttributeTest($attributeList[2], $executionID[2])) && p('0:id,attribute;1:id,attribute') && e('3,attribute;4,attribute'); //测试attributeList为attribute,executionID为2
|
||||
Reference in New Issue
Block a user