* Refactor getByProduct function.
This commit is contained in:
@@ -415,18 +415,16 @@ class testcaseModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据产品获取用例。
|
||||
* Get cases by product id.
|
||||
*
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getByProduct($productID)
|
||||
public function getByProduct(int $productID): array
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_CASE)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('product')->eq($productID)
|
||||
->fetchAll('id');
|
||||
return $this->dao->select('*')->from(TABLE_CASE)->where('deleted')->eq('0')->andWhere('product')->eq($productID)->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/testcase.class.php';
|
||||
su('admin');
|
||||
|
||||
function initData()
|
||||
{
|
||||
$caseData = zdTable('case');
|
||||
$caseData->product->range('1{6},2{4}');
|
||||
|
||||
$caseData->gen(10);
|
||||
}
|
||||
|
||||
initData();
|
||||
|
||||
/**
|
||||
|
||||
title=测试 testcaseModel->getBySuite();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 产品1用例有6个 @6
|
||||
- 产品2的用例有4个 @4
|
||||
|
||||
*/
|
||||
|
||||
$productIDList = array(1, 2);
|
||||
$branch = 0;
|
||||
$suiteIDList = array('1', '2', '3', '4');
|
||||
|
||||
global $tester;
|
||||
$tester->loadModel('testcase');
|
||||
|
||||
r(count($tester->testcase->getByProduct($productIDList[0]))) && p() && e(6); // 产品1的用例有6个
|
||||
r(count($tester->testcase->getByProduct($productIDList[1]))) && p() && e(4); // 产品2的用例有4个
|
||||
Reference in New Issue
Block a user