php - PHPUnit Mock Database Connection Class -
i'm adding unit tests legacy codes in mvc framework. have model class called dbconnection initiate database connection, looks this:
class dbconnection function __construct() { mysql_connect(hardcoded) } }
every methods needs database access call dbconnection, this:
function insertuser() { $db = new dbconnection(); $sql = "select ..... .... }
if want have option of either connect different testing database or using xml file mock database, how should without refactor code?
Comments
Post a Comment