Inside the setUp method I define $this->db = new ezSQL_mysql; so I guess that the object is reachable over all methods.
But when I execute testTableProject, I get an error on $this->db->get_var:
Fatal error: Call to a member function get_var() on a non-object in C:\AppServ\www\iap\Test\project\Iap\ProjectTest.php on line 43
Code: Select all
class tableTest extends PHPUnit_Framework_TestCase
{
protected $db;
public function setUp()
{
$this->db = new ezSQL_mysql;
echo $this->db->get_var("SELECT COUNT(*) FROM myTable"); //this works
}
public function tearDown()
{
unset($this->db);
}
public function testTableProject()
{
echo $num = $this->db->get_var("SELECT COUNT(*) FROM myTable"); //this is not working
$this->assertEquals(1, $num);
}
}
$tableTest = new tableTest();
$tableTest->testTableProject();
I'm new with phpunit, maybe I'm doing something wrong.
Thanks in advance