From be52789be67654bb181ee2a4132fbbddef79b91a Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Mon, 18 Sep 2023 14:31:31 +0800 Subject: [PATCH] + Add unit test for product checkAccess. --- module/product/test/model/checkaccess.php | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 module/product/test/model/checkaccess.php diff --git a/module/product/test/model/checkaccess.php b/module/product/test/model/checkaccess.php new file mode 100755 index 0000000000..acf97c3b4a --- /dev/null +++ b/module/product/test/model/checkaccess.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +gen(10); +su('admin'); + +/** + +title=测试 productModel::checkAccess; +timeout=0 +cid=1 + +*/ + +global $tester; +$tester->loadModel('product'); + +$products = array(1 => 1, 2 => 2, 6 => 6); +$idList = array(0, 6, 10); +r($tester->product->checkAccess($idList[0], $products)) && p() && e('1'); //不传入ID +r($tester->product->checkAccess($idList[1], $products)) && p() && e('6'); //传入存在ID的值 +r($tester->product->checkAccess($idList[0], $products)) && p() && e('1'); //不传入ID,读取session信息 +r($tester->product->checkAccess($idList[2], $products)) && p() && e('10'); //传入正确的ID