diff --git a/module/product/test/lib/zen.class.php b/module/product/test/lib/zen.class.php index 63632e6c5b..e49d480cc0 100644 --- a/module/product/test/lib/zen.class.php +++ b/module/product/test/lib/zen.class.php @@ -949,4 +949,48 @@ class productZenTest extends baseTest return $sendData; } + + /** + * Test saveAndModifyCookie4Browse method. + * + * @param int $productID + * @param string $branch + * @param int $param + * @param string $browseType + * @param string $orderBy + * @param string $preProductID + * @param string $preBranch + * @param string $storyModule + * @param string $tab + * @access public + * @return array + */ + public function saveAndModifyCookie4BrowseTest(int $productID = 0, string $branch = '', int $param = 0, string $browseType = '', string $orderBy = 'id_desc', string $preProductID = '', string $preBranch = '', string $storyModule = '', string $tab = 'product') + { + /* Set up cookie values. */ + if($preProductID !== '') $_COOKIE['preProductID'] = $preProductID; + if($preBranch !== '') $_COOKIE['preBranch'] = $preBranch; + if($storyModule !== '') $_COOKIE['storyModule'] = $storyModule; + + /* Set app tab. */ + $this->instance->app->tab = $tab; + + /* Call the method. */ + $this->invokeArgs('saveAndModifyCookie4Browse', array($productID, $branch, $param, $browseType, $orderBy)); + + /* Get the cookie values after method execution. */ + $result = array( + 'storyModule' => isset($_COOKIE['storyModule']) ? $_COOKIE['storyModule'] : '', + 'storyModuleParam' => isset($_COOKIE['storyModuleParam']) ? $_COOKIE['storyModuleParam'] : '', + 'storyBranch' => isset($_COOKIE['storyBranch']) ? $_COOKIE['storyBranch'] : '', + 'treeBranch' => isset($_COOKIE['treeBranch']) ? $_COOKIE['treeBranch'] : '', + 'productStoryOrder' => isset($_COOKIE['productStoryOrder']) ? $_COOKIE['productStoryOrder'] : '', + 'preProductID' => isset($_COOKIE['preProductID']) ? $_COOKIE['preProductID'] : '', + 'preBranch' => isset($_COOKIE['preBranch']) ? $_COOKIE['preBranch'] : '' + ); + + if(dao::isError()) return dao::getError(); + + return $result; + } } diff --git a/module/product/test/zen/saveandmodifycookie4browse.php b/module/product/test/zen/saveandmodifycookie4browse.php new file mode 100755 index 0000000000..e06d741a63 --- /dev/null +++ b/module/product/test/zen/saveandmodifycookie4browse.php @@ -0,0 +1,46 @@ +#!/usr/bin/env php +saveAndModifyCookie4BrowseTest(2, 'all', 0, '', 'id_desc', '1', 'all', '100')) && p('storyModule') && e('0'); + +/* 测试步骤2:分支切换时清除storyModule cookie。*/ +r($productTest->saveAndModifyCookie4BrowseTest(1, 'branch2', 0, '', 'id_desc', '1', 'branch1', '100')) && p('storyModule') && e('0'); + +/* 测试步骤3:按模块浏览时设置storyModule cookie。*/ +r($productTest->saveAndModifyCookie4BrowseTest(1, 'all', 10, 'bymodule', 'id_desc', '1', 'all', '0')) && p('storyModule') && e('10'); + +/* 测试步骤4:项目视图中按模块浏览时设置storyModuleParam。*/ +r($productTest->saveAndModifyCookie4BrowseTest(1, 'all', 20, 'bymodule', 'id_desc', '1', 'all', '0', 'project')) && p('storyModuleParam') && e('20'); + +/* 测试步骤5:按分支浏览时设置storyBranch cookie。*/ +r($productTest->saveAndModifyCookie4BrowseTest(1, 'branch1', 0, 'bybranch', 'id_desc', '1', 'all', '0')) && p('storyBranch') && e('branch1'); + +/* 测试步骤6:设置产品需求列表排序cookie。*/ +r($productTest->saveAndModifyCookie4BrowseTest(1, 'all', 0, '', 'pri_desc', '1', 'all', '0')) && p('productStoryOrder') && e('pri_desc'); + +/* 测试步骤7:设置preProductID cookie。*/ +r($productTest->saveAndModifyCookie4BrowseTest(5, 'all', 0, '', 'id_desc', '1', 'all', '0')) && p('preProductID') && e('5'); \ No newline at end of file