* Add unit test for product-concatProductLine.

This commit is contained in:
zhouxin
2023-05-19 08:23:43 +00:00
parent 560db40e89
commit 6424575615
5 changed files with 84 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . "/test/lib/init.php";
include dirname(__FILE__, 2) . '/product.class.php';
zdTable('module')->config('line')->gen(5);
zdTable('product')->config('product')->gen(30);
/**
title=productModel->concatProductLine();
cid=1
pid=1
*/
$product = new productTest('admin');
$lineList = array(1, 2, 3, 4, 5);
$line1Products = range(1, 5);
$line2Products = range(6, 10);
$line3Products = range(11, 15);
$line4Products = range(16, 20);
$line5Products = range(21, 25);
$noLineProducts = range(26,30);
$testSuit1 = array_merge($line1Products, $line2Products, $line3Products);
$testSuit2 = array_merge($line3Products, $line4Products, $line5Products);
$testSuit3 = array_merge($line3Products, $line4Products, $noLineProducts);
r($product->concatProductLineTest($testSuit1)) && p('0:name;1:name;2:name') && e('产品线1/产品1,产品线1/产品2,产品线1/产品3'); // 测试第一组产品列表的0,1,2条数据
r($product->concatProductLineTest($testSuit1)) && p('5:name;6:name;7:name') && e('产品线2/产品6,产品线2/产品7,产品线2/产品8'); // 测试第一组产品列表的5,6,7条数据
r($product->concatProductLineTest($testSuit1)) && p('10:name;11:name;12:name') && e('产品线3/产品11,产品线3/产品12,产品线3/产品13'); // 测试第一组产品列表的10,11,12条数据
r($product->concatProductLineTest($testSuit2)) && p('0:name;1:name;2:name') && e('产品线3/产品11,产品线3/产品12,产品线3/产品13'); // 测试第二组产品列表的0,1,2条数据
r($product->concatProductLineTest($testSuit2)) && p('5:name;6:name;7:name') && e('产品线4/产品16,产品线4/产品17,产品线4/产品18'); // 测试第二组产品列表的5,6,7条数据
r($product->concatProductLineTest($testSuit2)) && p('10:name;11:name;12:name') && e('产品线5/产品21,产品线5/产品22,产品线5/产品23'); // 测试第二组产品列表的10,11,12条数据
r($product->concatProductLineTest($testSuit3)) && p('0:name;1:name;2:name') && e('产品线3/产品11,产品线3/产品12,产品线3/产品13'); // 测试第三组产品列表的0,1,2条数据
r($product->concatProductLineTest($testSuit3)) && p('5:name;6:name;7:name') && e('产品线4/产品16,产品线4/产品17,产品线4/产品18'); // 测试第三组产品列表的5,6,7条数据
r($product->concatProductLineTest($testSuit3)) && p('10:name;11:name;12:name') && e('产品26,产品27,产品28'); // 测试第三组产品列表的10,11,12条数据
@@ -3,6 +3,7 @@
include dirname(__FILE__, 5) . "/test/lib/init.php";
include dirname(__FILE__, 2) . '/product.class.php';
su('admin');
/**
title=测试productModel->updateProjects();
@@ -0,0 +1,13 @@
title: product line
desc: Build product line data.
author: zhouxin
version: 1.0.0
fields:
- field: type
range: 'line'
- field: name
range: 1-5
prefix: '产品线'
- field: root
range: 1
@@ -0,0 +1,15 @@
title: product data
desc: Build product data.
author: zhouxin
version: 1.0.0
fields:
- field: name
range: 1-30
prefix: '产品'
- field: program
range: 1
- field: line
range: 1{5},2{5},3{5},4{5},5{5},6{5}
- field: status
range: 'normal'
+14
View File
@@ -1054,6 +1054,20 @@ class productTest
}
}
/**
* Test for concat product line.
*
* @param array $productIdList
* @access public
* @return object[]
*/
public function concatProductLineTest(array $productIdList): array
{
$this->config->systemMode == 'ALM';
$products = $this->objectModel->dao->select('*')->from(TABLE_PRODUCT)->where('id')->in($productIdList)->fetchAll();
return $this->objectModel->concatProductLine($products);
}
/**
* 测试创建产品主库
* Test for create main lib.