From a14b6e50b5c0061476093a2ea69422f8e7cfa3fe Mon Sep 17 00:00:00 2001 From: liumengyi Date: Thu, 24 Mar 2022 09:18:05 +0800 Subject: [PATCH] * Add auto test of todo. --- test/class/todo.class.php | 10 +++++++--- test/data/todocycle.yaml | 4 ++-- test/data/zentao/processor.php | 6 +++--- test/model/todo/createbycycle.php | 10 ++++++++-- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/test/class/todo.class.php b/test/class/todo.class.php index feb204e7c1..0f5696d4ed 100755 --- a/test/class/todo.class.php +++ b/test/class/todo.class.php @@ -5,6 +5,7 @@ class todoTest { global $tester; $this->objectModel = $tester->loadModel('todo'); + $tester->app->loadClass('dao'); } /** @@ -276,10 +277,13 @@ class todoTest $todo->config = str_replace('2022-03-23', date('Y-m-d', time()), $todo->config); - $this->objectModel->createByCycle(array('1' => $todo)); - global $tester; - $objects = $tester->dao->select('id')->from(TABLE_TODO)->where('idvalue')->eq('100001')->andWhere('name')->eq($todo->name)->andWhere('config')->eq($todo->config)->andWhere('deleted')->eq('0')->fetchAll(); + $tester->dao->insert(TABLE_TODO)->data($todo)->autoCheck()->exec(); + $todoID = $tester->dao->lastInsertID(); + + $this->objectModel->createByCycle(array($todoID => $todo)); + + $objects = $tester->dao->select('id')->from(TABLE_TODO)->where('idvalue')->eq($todoID)->andWhere('deleted')->eq('0')->fetchAll(); if(dao::isError()) return dao::getError(); diff --git a/test/data/todocycle.yaml b/test/data/todocycle.yaml index 17a82f50e4..7265f5900c 100644 --- a/test/data/todocycle.yaml +++ b/test/data/todocycle.yaml @@ -45,12 +45,12 @@ fields: postfix: "" - field: cycle note: "周期" - range: 1,0 + range: 1 prefix: "" postfix: "" - field: idvalue note: "关联编号" - range: 0,2001,0,2003,0 + range: 0 prefix: "" postfix: "" loop: 0 diff --git a/test/data/zentao/processor.php b/test/data/zentao/processor.php index 643efc1709..eb89bfef49 100644 --- a/test/data/zentao/processor.php +++ b/test/data/zentao/processor.php @@ -319,9 +319,9 @@ class Processor $toDay = date('y-m-d'); $addDay = date('Y-m-d',strtotime("+1 day")); - $str = '{"day":"1","specify":{"month":"0","day":"1"},"type":"day","beforeDays":1,"end":"","begin":"'.$toDay.'"}'; - $str2 = '{"specify":{"month":"0","day":"1"},"week":"3","type":"week","beforeDays":1,"end":"","begin":"'.$toDay.'"}'; - $str3 = '{"specify":{"month":"0","day":"1"},"month":"17","type":"month","beforeDays":0,"end":"","begin":"'.$toDay.'"}'; + $str = '{"day":"1","specify":{"month":"0","day":"1"},"type":"day","beforeDays":11,"end":"","begin":"'.$toDay.'"}'; + $str2 = '{"specify":{"month":"0","day":"1"},"week":"1,3","type":"week","beforeDays":31,"end":"","begin":"'.$toDay.'"}'; + $str3 = '{"specify":{"month":"0","day":"1"},"month":"5,17,29","type":"month","beforeDays":301,"end":"","begin":"'.$toDay.'"}'; $this->dao->update(TABLE_TODO)->SET('config')->eq($str)->where('id')->eq('2001')->exec(); $this->dao->update(TABLE_TODO)->SET('date')->eq($addDay)->where('id')->eq('2002')->exec(); diff --git a/test/model/todo/createbycycle.php b/test/model/todo/createbycycle.php index 9df8306ce0..a6e04a29aa 100755 --- a/test/model/todo/createbycycle.php +++ b/test/model/todo/createbycycle.php @@ -10,11 +10,15 @@ title=测试 todoModel->createByCycle(); cid=1 pid=1 +测试创建周期日待办 >> 11 +测试创建周期周待办 >> 9 +测试创建周期月待办 >> 30 + */ $todo1 = new stdclass(); $todo1->name = 'cycle生成的待办1'; -$todo1->config = '{"specify":{"month":"0","day":"1"},"days":"1","type":"day","beforeDays":11,"end":"","begin":"2022-03-23"}'; +$todo1->config = '{"specify":{"month":"0","day":"1"},"day":"1","type":"day","beforeDays":11,"end":"","begin":"2022-03-23"}'; $todo2 = new stdclass(); $todo2->name = 'cycle生成的待办2'; @@ -26,4 +30,6 @@ $todo3->config = '{"specify":{"month":"0","day":"1"},"month":"1,8,13 $todo = new todoTest(); -r($todo->createByCycleTest($todo1)) && p() && e(''); +r($todo->createByCycleTest($todo1)) && p() && e('11'); // 测试创建周期日待办 +r($todo->createByCycleTest($todo2)) && p() && e('9'); // 测试创建周期周待办 +r($todo->createByCycleTest($todo3)) && p() && e('30'); // 测试创建周期月待办