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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -