I have built new functionality into a very large website. The functionality works flawlessly in browser, but phpunit tests are dying in what looks to be CodeIgniter basic code.
Call to undefined method CI_DB_mysql_driver::where() in (... privacy ..)/application/models/tank_auth/users.php on line 36
users.php (the function that's dying)
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
* This model represents user authentication data. It operates the following tables:
* - user account data,
* - user profiles
* @package Tank_auth
* @author Ilya Konyukhov (http://konyukhov.com/soft/)
class Users extends CI_Model
private $table_name = 'users'; // user accounts
private $profile_table_name = 'user_profiles'; // user profiles
$ci =& get_instance();
$this->table_name = $ci->config->item('db_table_prefix', 'tank_auth').$this->table_name;
$this->profile_table_name = $ci->config->item('db_table_prefix', 'tank_auth').$this->profile_table_name;
* Get user record by Id
* @param int
* @param bool
* @return object
function get_user_by_id($user_id, $activated)
$this->db->where('activated', $activated ? 1 : 0);
$query = $this->db->get($this->table_name);
if ($query->num_rows() == 1) return $query->row();
Google searches aren't returning anything of use. I've checked the database.php file and have found
$active_records = TRUE;
with no other references that could be overwriting this variable. This is also an error that has NOT been found in testing any other code by any other member of our development team, so I'm not getting any internal help with this.
I have written a ton of tests for this website and have not come across this before. Any tips or nudges in the right direction would be appreciated!
Finally got help from a coworker. we changed a driver:
class MY_DB_driver extends \CI_DB_active_record
We had it set to \CI_DB_driver, which was killing the $active_record variable.