CodeIgniter Forums
Issue while running phpunit in codeigniter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forum-17.html)
+--- Thread: Issue while running phpunit in codeigniter (/thread-73136.html)



Issue while running phpunit in codeigniter - Rekha - 03-22-2019

Hi,
I am new to PHPUnit tests for CodeIgniter application. I have installed ci-phpunit-test(with reference from https://github.com/kenjis/ci-phpunit-test) in my CI application and tried to run it with Welcome Test case. Then I got some errors. I am not sure whether I missed any configuration. Please find the issues below,

  1. Undefined index: scheme in DB.php line number 121. Then, I statically gave mysqli instead of $dns['scheme'] to check further.

  2. After 1, got an error such Error: Call to a member function close() on string in the file mysqli_driver line number 541. Then I commented this line and executed the phpunit. Welcome controller got tested successfully.

  3. So, I thought to test the model and then I wrote a test and executed. The error is Error: Call to a member function result() on null. Model Code below,
    $this->db->select('name,value'); $query = $this->db->get('config'); $configData=$query->result();
I tried to fix it by myself but I couldn't. Please help me to fix these errors.