Files
EasySoft-ZenTaoPMS/test/api/products/create.php
2021-10-25 14:48:21 +08:00

34 lines
1.7 KiB
PHP
Raw 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
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
/**
title=测试创建产品;
cid=1
pid=1
*/
global $token;
$header = array('Token' => $token->token);
$pass = $rest->post('/products', array('name' => 'CESHI1', 'program' => '1', 'code' => 'CESHI1'), $header);
r($pass) && c(200) && p('name,code') && e('CESHI1,CESHI1'); //测试创建所属项目集为1的产品
$noProgram = $rest->post('/products', array('name' => 'CESHI2', 'code' => 'CESHI2'), $header);
r($noProgram) && c(200) && p('program') && e('0'); //测试创建独立产品
$emptyName = $rest->post('/products', array(), $header);
r($emptyName) && c(400) && p('error') && e('『产品名称』不能为空。'); //测试产品名称为空的情况
$emptyCode = $rest->post('/products', array('name' => 'CESHI3'), $header);
r($emptyCode) && c(400) && p('error') && e('『产品代号』不能为空。'); //测试产品代号为空的情况
$existedName = $rest->post('/products', array('name' => 'CESHI1', 'code' => 'CESHI4'), $header);
r($existedName->status_code) && p() && e('400'); //测试状态码
r($existedName->body->error) && p('name:0') && e('『产品名称』已经有『CESHI1』这条记录了。如果您确定该记录已删除请到后台-系统-数据-回收站还原。'); //测试产品名称已存在
$existedCode = $rest->post('/products', array('name' => 'CESHI4','code' => 'CESHI1'), $header);
r($existedCode->status_code) && p() && e('400'); //测试状态码
r($existedCode->body->error) && p('code:0') && e('『产品代号』已经有『CESHI1』这条记录了。如果您确定该记录已删除请到后台-系统-数据-回收站还原。'); //测试产品代号已存在