+ Add unit test for product formatDataForList.

This commit is contained in:
caoyanyi
2023-09-20 15:39:16 +08:00
parent 5dc39556f6
commit b0b18b15fb
2 changed files with 29 additions and 0 deletions
@@ -0,0 +1,21 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/product.class.php';
zdTable('product')->gen(3);
/**
title=测试productModel->formatDataForList();
cid=1
pid=1
*/
$product = new productTest();
$idList = array(1, 0, 5);
r($product->formatDataForListTest($idList[0])) && p('name,type') && e('正常产品1,product'); // 正常产品
r($product->formatDataForListTest($idList[1])) && p() && e('0'); // 错误的产品
r($product->formatDataForListTest($idList[2])) && p() && e('0'); // 不存在的产品
+8
View File
@@ -1107,6 +1107,14 @@ class productTest
return $_SESSION['storysearchParams']['queryID'];
}
public function formatDataForListTest($productID)
{
$product = $this->objectModel->getStats(array($productID));
if(!$product) return false;
return $this->objectModel->formatDataForList($product[$productID], array());
}
/**
* Test summary method.
*