+ [misc] Add unit tests for caselibZen::getFieldsForImport() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -767,4 +767,35 @@ class caselibTest
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getFieldsForImport method.
|
||||
*
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return array|int|string
|
||||
*/
|
||||
public function getFieldsForImportTest(string $type = 'array')
|
||||
{
|
||||
$zen = initReference('caselib');
|
||||
$method = $zen->getMethod('getFieldsForImport');
|
||||
$zenInstance = $zen->newInstance();
|
||||
|
||||
$result = $method->invoke($zenInstance);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
if($type == 'count') return count($result);
|
||||
if($type == 'keys') return array_keys($result);
|
||||
if($type == 'values') return array_values($result);
|
||||
if($type == 'first_key' && !empty($result)) return key($result);
|
||||
if($type == 'first_value' && !empty($result)) return reset($result);
|
||||
if($type == 'has_title') return isset($result['标题']) ? 1 : 0;
|
||||
if($type == 'has_module') return isset($result['所属模块']) ? 1 : 0;
|
||||
if($type == 'has_precondition') return isset($result['前置条件']) ? 1 : 0;
|
||||
if($type == 'has_stepDesc') return isset($result['步骤']) ? 1 : 0;
|
||||
if($type == 'has_stepExpect') return isset($result['预期']) ? 1 : 0;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 caselibZen::getFieldsForImport();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行caselibTest模块的getFieldsForImportTest方法,参数是'count' @9
|
||||
- 执行caselibTest模块的getFieldsForImportTest方法 属性用例名称 @title
|
||||
- 执行caselibTest模块的getFieldsForImportTest方法 属性所属模块 @module
|
||||
- 执行caselibTest模块的getFieldsForImportTest方法 属性步骤 @stepDesc
|
||||
- 执行caselibTest模块的getFieldsForImportTest方法 属性预期 @stepExpect
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/caselib.unittest.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$caselibTest = new caselibTest();
|
||||
|
||||
r($caselibTest->getFieldsForImportTest('count')) && p() && e('9');
|
||||
r($caselibTest->getFieldsForImportTest()) && p('用例名称') && e('title');
|
||||
r($caselibTest->getFieldsForImportTest()) && p('所属模块') && e('module');
|
||||
r($caselibTest->getFieldsForImportTest()) && p('步骤') && e('stepDesc');
|
||||
r($caselibTest->getFieldsForImportTest()) && p('预期') && e('stepExpect');
|
||||
Reference in New Issue
Block a user