mercredi 24 février 2016

PHPUnit - PHP Fatal error: Call to a member function GetOne() on null

I started today to use PHPUnit Tests on PhpStorm. I could test almost all functions, except the functions which requires database connection.

Function:

public function getProductID()
{
     $this->product_id = $this->db->GetOne("select product_id from table1 where id = {$this->id}");
     return $this->product_id['product_id'];
}

On my test case, I got error:

PHP Fatal error: Call to a member function GetOne() on null

I have defined:

global $_db;
$this->db = $_db;

Aucun commentaire:

Enregistrer un commentaire