I am writing my first phpunit test, here is class for test
require_once "../../configure.php";
class OrderTest extends PHPUnit_Framework_TestCase
{
public function testLoadOrder_O275()
{
$o = new Order(275);
$this->assertEquals(275, $o->OrderID);
}
public function testLoadOrder_O1_Fail(){
$o2 = new Order(1);
$this->assertEquals(1, $o2->OrderID);
}
}
I have two other classes which are autoload using my configure.php, first is DB class that connect to db using mysqli
extension and other is Order
class that take int as input for construct and load it from database.
My first test succeed to load but second test gives
DB::Execute(): Couldn't fetch mysqli
Where DB
is class name and Execute
is my public function in that class [not static]. If I reverse the order of functions then first function start giving same error, but later works. Any reason? or solution?
Aucun commentaire:
Enregistrer un commentaire