【问题标题】:database testing in php using phpunit,simpletest on api haveing stored procedure使用phpunit在php中进行数据库测试,对具有存储过程的api进行简单测试
【发布时间】:2014-02-13 13:23:19
【问题描述】:
【问题讨论】:
标签:
php
stored-procedures
phpunit
dbunit
simpletest
【解决方案1】:
有示例代码如何在 phpunit 中测试存储过程
public function delete($userId)
{
// this function calls a stored procedure
$sql = "CALL Delete_User_Details(:userId)";
try {
$db = parent::getConnection();
$stmt = $db->prepare($sql);
$stmt->bindParam("userId", $userId);
$stmt->execute();
$id = $stmt->fetchObject();
if ($id == null) {
$delete_response->createJSONArray("DATABASE_ERROR",0);
} else {
$delete_response->createJSONArray("SUCCESS",1);
}
} catch (PDOException $e) {
$delete_response->createJSONArray("DATABASE_ERROR",0);
}
return $delete_response->toJSON();
}