+ Add unit test for product deleteByID.

This commit is contained in:
caoyanyi
2023-09-19 10:23:29 +08:00
parent bff85c894e
commit 822e8e65d3
2 changed files with 34 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/product.class.php';
su('admin');
zdTable('product')->gen(5);
/**
title=测试productModel->deleteByID();
timeout=0
cid=1
*/
$product = new productTest('admin');
r($product->deleteByIdTest(0)) && p() && e('0'); // ID为空
r($product->deleteByIdTest(1)) && p('name,deleted') && e('正常产品1,1'); // 正常删除
r($product->deleteByIdTest(10)) && p() && e('0'); // 不存在的ID
+13
View File
@@ -1043,4 +1043,17 @@ class productTest
$this->objectModel->deleteLine($lineID);
return $this->objectModel->dao->select('*')->from(TABLE_MODULE)->where('id')->eq($lineID)->fetch();
}
/**
* Test deleteByID method.
*
* @param int $productID
* @access public
* @return void
*/
public function deleteByIdTest(int $productID)
{
$this->objectModel->deleteByID($productID);
return $this->objectModel->getByID($productID);
}
}