diff --git a/module/pivot/test/lib/pivot.unittest.class.php b/module/pivot/test/lib/pivot.unittest.class.php index a3d0213cd6..87ffa7a05f 100644 --- a/module/pivot/test/lib/pivot.unittest.class.php +++ b/module/pivot/test/lib/pivot.unittest.class.php @@ -1572,4 +1572,21 @@ class pivotTest return $result; } + + /** + * Test fetchPivotDrills method. + * + * @param int $pivotID + * @param string $version + * @param string|array $fields + * @access public + * @return array + */ + public function fetchPivotDrillsTest(int $pivotID, string $version, string|array $fields): array + { + $result = $this->objectTao->fetchPivotDrills($pivotID, $version, $fields); + if(dao::isError()) return dao::getError(); + + return $result; + } } \ No newline at end of file diff --git a/module/pivot/test/tao/fetchpivotdrills.php b/module/pivot/test/tao/fetchpivotdrills.php new file mode 100755 index 0000000000..761844d021 --- /dev/null +++ b/module/pivot/test/tao/fetchpivotdrills.php @@ -0,0 +1,52 @@ +#!/usr/bin/env php +dao->delete()->from(TABLE_PIVOTDRILL)->exec(); + +// 插入测试数据 +$testData = array( + array('pivot' => 1, 'version' => '1', 'field' => 'name', 'object' => 'bug', 'whereSql' => 'status = "active"', 'condition' => '{"field":"status","operator":"=","value":"active"}', 'status' => 'published', 'account' => 'admin', 'type' => 'manual'), + array('pivot' => 1, 'version' => '1', 'field' => 'status', 'object' => 'bug', 'whereSql' => 'deleted = "0"', 'condition' => '{"field":"deleted","operator":"=","value":"0"}', 'status' => 'published', 'account' => 'admin', 'type' => 'manual'), + array('pivot' => 2, 'version' => '2', 'field' => 'status', 'object' => 'story', 'whereSql' => 'type = "story"', 'condition' => '{"field":"type","operator":"=","value":"story"}', 'status' => 'published', 'account' => 'user1', 'type' => 'auto'), + array('pivot' => 2, 'version' => '2', 'field' => 'category', 'object' => 'story', 'whereSql' => '', 'condition' => '{}', 'status' => 'design', 'account' => 'user1', 'type' => 'auto'), + array('pivot' => 3, 'version' => '3', 'field' => 'priority', 'object' => 'task', 'whereSql' => 'priority > 1', 'condition' => '{"field":"priority","operator":">","value":"1"}', 'status' => 'published', 'account' => 'admin', 'type' => 'manual') +); + +foreach($testData as $data) { + $tester->dao->insert(TABLE_PIVOTDRILL)->data($data)->exec(); +} + +// 4. 创建测试实例(变量名与模块名一致) +$pivotTest = new pivotTest(); + +// 3. 用户登录(选择合适角色) +su('admin'); + +// 5. 强制要求:必须包含至少5个测试步骤 +r($pivotTest->fetchPivotDrillsTest(1, '1', 'name')) && p('name:field') && e('name'); // 步骤1:正常情况 - 获取单个字段 +r(count($pivotTest->fetchPivotDrillsTest(2, '2', array('status', 'category')))) && p() && e('2'); // 步骤2:正常情况 - 获取多个字段 +r(count($pivotTest->fetchPivotDrillsTest(999, '1', 'name'))) && p() && e('0'); // 步骤3:边界值 - 不存在的透视表ID +r(count($pivotTest->fetchPivotDrillsTest(1, 'nonexistent', 'name'))) && p() && e('0'); // 步骤4:边界值 - 不存在的版本号 +r(count($pivotTest->fetchPivotDrillsTest(1, '1', 'nonexistent_field'))) && p() && e('0'); // 步骤5:边界值 - 不存在的字段名 \ No newline at end of file diff --git a/module/pivot/test/tao/yaml/pivotdrill_fetchpivotdrills.yaml b/module/pivot/test/tao/yaml/pivotdrill_fetchpivotdrills.yaml new file mode 100644 index 0000000000..1f1afc2622 --- /dev/null +++ b/module/pivot/test/tao/yaml/pivotdrill_fetchpivotdrills.yaml @@ -0,0 +1,34 @@ +--- +title: 透视表下钻配置测试数据 +desc: 用于测试fetchPivotDrills方法的测试数据 +author: Claude +version: 1.0 + +fields: +- field: pivot + note: 透视表ID + range: 1-3 +- field: version + note: 版本号 + range: 1,2,3 +- field: field + note: 字段名称 + range: name,status,category +- field: object + note: 对象类型 + range: bug,story +- field: whereSql + note: WHERE SQL条件 + range: 'status = "active"','deleted = "0"','type = "story"' +- field: condition + note: 条件配置JSON + range: '{"field":"status","operator":"=","value":"active"}','{"field":"deleted","operator":"=","value":"0"}','{}' +- field: status + note: 状态 + range: published,design +- field: account + note: 创建者 + range: admin,user1 +- field: type + note: 类型 + range: manual,auto \ No newline at end of file