znt/module/product/test/zen/buildproductforedit.php

81 lines
2.7 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 productZen::buildProductForEdit();
timeout=0
cid=17566
- 执行productTest模块的buildProductForEditTest方法参数是1, 0
- 属性name @Updated Product 1
- 属性PO @admin
- 属性status @normal
- 执行productTest模块的buildProductForEditTest方法参数是2, 1
- 属性name @Updated Product 2
- 属性type @branch
- 属性status @normal
- 执行productTest模块的buildProductForEditTest方法参数是3, 0
- 属性name @Updated Product 3
- 属性acl @open
- 属性whitelist @~~
- 执行productTest模块的buildProductForEditTest方法参数是4, 0
- 属性name @Updated Product 4
- 属性acl @private
- 属性whitelist @user1,user2
- 执行productTest模块的buildProductForEditTest方法参数是5, 0
- 属性name @Updated Product 5
- 属性status @closed
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zen.class.php';
zendata('product')->gen(5);
su('admin');
$productTest = new productZenTest();
// 测试步骤1:使用有效产品ID(1)和基本POST数据编辑产品
$_POST['name'] = 'Updated Product 1';
$_POST['PO'] = 'admin';
$_POST['type'] = 'normal';
$_POST['acl'] = 'open';
$_POST['desc'] = 'Updated description';
$_POST['status'] = 'normal';
r($productTest->buildProductForEditTest(1, 0)) && p('name,PO,status') && e('Updated Product 1,admin,normal');
// 测试步骤2:使用workflowGroup参数1编辑产品
$_POST['name'] = 'Updated Product 2';
$_POST['PO'] = 'admin';
$_POST['type'] = 'branch';
$_POST['acl'] = 'private';
$_POST['desc'] = 'Updated description 2';
$_POST['status'] = 'normal';
r($productTest->buildProductForEditTest(2, 1)) && p('name,type,status') && e('Updated Product 2,branch,normal');
// 测试步骤3:测试acl为open时whitelist字段被清空
$_POST['name'] = 'Updated Product 3';
$_POST['PO'] = 'admin';
$_POST['acl'] = 'open';
$_POST['whitelist'] = 'user1,user2';
$_POST['status'] = 'normal';
r($productTest->buildProductForEditTest(3, 0)) && p('name,acl,whitelist') && e('Updated Product 3,open,~~');
// 测试步骤4:测试acl为private时whitelist字段保留
$_POST['name'] = 'Updated Product 4';
$_POST['PO'] = 'admin';
$_POST['acl'] = 'private';
$_POST['whitelist'] = array('user1', 'user2');
$_POST['status'] = 'normal';
r($productTest->buildProductForEditTest(4, 0)) && p('name;acl;whitelist', ';') && e('Updated Product 4;private;user1,user2');
// 测试步骤5:测试编辑产品状态字段
$_POST['name'] = 'Updated Product 5';
$_POST['PO'] = 'admin';
$_POST['type'] = 'normal';
$_POST['acl'] = 'open';
$_POST['status'] = 'closed';
r($productTest->buildProductForEditTest(5, 0)) && p('name,status') && e('Updated Product 5,closed');