znt/module/todo/test/model/create.php

60 lines
2.1 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
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
su('admin');
zenData('todo')->loadYaml('create')->gen(5);
/**
title=测试 todoModel->create();
timeout=0
cid=19251
- 判断创建的待办数据name字段为空返回结果id为0 @0
- 判断创建的待办数据objectID字段错误返回结果id为0 @0
- 判断创建待办返回结果id为6 @6
- 判断创建周期待办返回结果id为7 @7
- 判断空待办 @~~
*/
global $tester;
$tester->loadModel('todo');
$today = date('Y-m-d');
$todo = new stdclass();
$todo->name = 'TODO Create Test';
$todo->account = 'admin';
$todo->date = $today;
$todo->type = 'custom';
$todo->begin = '0800';
$todo->end = '1700';
$todo->assignedTo = 'admin';
$todo->assignedBy = 'admin';
$todo->assignedDate = $today;
$todoWithoutName = clone $todo;
$todoWithoutName->name = '';
$randModuleKey = array_rand($tester->config->todo->moduleList, 1);
$todoInvalidObjectID = clone $todo;
$todoInvalidObjectID->name = 'todoInvalidObjectID';
$todoInvalidObjectID->type = $tester->config->todo->moduleList[$randModuleKey];
$todoInvalidObjectID->objectID = 0;
$todoWithCycle = clone $todo;
$todoWithCycle->type = 'cycle';
$todoWithCycle->cycle = 1;
$todoWithCycle->config = json_encode(array('day' => 1, 'specify' => array('month' => 0, 'day' => 1), 'type' => 'day', 'beforeDays' => 1, 'end' => ''));
$todoWithCycle->objectID = 0;
$todoTest = new todoModelTest();
r($todoTest->createTest($todoWithoutName)) && p() && e('0'); // 判断创建的待办数据name字段为空返回结果id为0
r($todoTest->createTest($todoInvalidObjectID)) && p() && e('0'); // 判断创建的待办数据objectID字段错误返回结果id为0
dao::getError();
r($todoTest->createTest($todo)) && p() && e('6'); // 判断创建待办返回结果id为6
r($todoTest->createTest($todoWithCycle)) && p() && e('7'); // 判断创建周期待办返回结果id为7
r($todoTest->createTest(null)) && p() && e('~~'); // 判断空待办