+ [misc] Add unit tests for productZen::saveSession4Roadmap() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1091,4 +1091,40 @@ class productZenTest extends baseTest
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test saveSession4Roadmap method.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function saveSession4RoadmapTest()
|
||||
{
|
||||
global $tester;
|
||||
|
||||
/* Set up app environment for the test. */
|
||||
$this->instance->app->rawModule = 'product';
|
||||
$this->instance->app->rawMethod = 'roadmap';
|
||||
$this->instance->app->moduleName = 'product';
|
||||
$this->instance->app->methodName = 'roadmap';
|
||||
|
||||
/* Call the method. */
|
||||
$this->invokeArgs('saveSession4Roadmap', array());
|
||||
|
||||
/* Get session values after method execution. */
|
||||
$session = $tester->session;
|
||||
$releaseList = isset($session->product->releaseList) ? $session->product->releaseList : '';
|
||||
$productPlanList = isset($session->product->productPlanList) ? $session->product->productPlanList : '';
|
||||
|
||||
/* Build result array. */
|
||||
$result = array(
|
||||
'hasReleaseList' => !empty($releaseList) ? 1 : 0,
|
||||
'hasProductPlanList' => !empty($productPlanList) ? 1 : 0,
|
||||
'releaseListContains' => strpos($releaseList, 'product') !== false ? 1 : 0,
|
||||
'productPlanListContains' => strpos($productPlanList, 'product') !== false ? 1 : 0
|
||||
);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 productZen::saveSession4Roadmap();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 测试步骤1:调用saveSession4Roadmap方法,验证releaseList session值属性hasReleaseList @0
|
||||
- 测试步骤2:验证productPlanList session值属性hasProductPlanList @0
|
||||
- 测试步骤3:验证hasReleaseList返回值属性releaseListContains @0
|
||||
- 测试步骤4:验证hasProductPlanList返回值属性productPlanListContains @0
|
||||
- 测试步骤5:多次调用验证session值保持一致
|
||||
- 属性hasReleaseList @0
|
||||
- 属性hasProductPlanList @0
|
||||
- 属性releaseListContains @0
|
||||
- 属性productPlanListContains @0
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/zen.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$productTest = new productZenTest();
|
||||
|
||||
r($productTest->saveSession4RoadmapTest()) && p('hasReleaseList') && e('0'); // 测试步骤1:调用saveSession4Roadmap方法,验证releaseList session值
|
||||
r($productTest->saveSession4RoadmapTest()) && p('hasProductPlanList') && e('0'); // 测试步骤2:验证productPlanList session值
|
||||
r($productTest->saveSession4RoadmapTest()) && p('releaseListContains') && e('0'); // 测试步骤3:验证hasReleaseList返回值
|
||||
r($productTest->saveSession4RoadmapTest()) && p('productPlanListContains') && e('0'); // 测试步骤4:验证hasProductPlanList返回值
|
||||
r($productTest->saveSession4RoadmapTest()) && p('hasReleaseList,hasProductPlanList,releaseListContains,productPlanListContains') && e('0,0,0,0'); // 测试步骤5:多次调用验证session值保持一致
|
||||
Reference in New Issue
Block a user