Suppose the class Account (in account.php file) which uses a $DB variable to store data in the database. The $DB variable is initialized in another globals.php file.
/**** globals.php ****/
$DB = PDO (....);
/**** account.php ****/
public function create($data) { global $DB; .... }
Now, suppose that you want to test a function in account class called create using PHPUnit test. How would you initialize the $DB object?
Aucun commentaire:
Enregistrer un commentaire