Welcome Guest, Not a member yet? Register   Sign In
Problem with CIUnit fooLoader.php
#1

[eluser]pinksy[/eluser]
Hi,

I've been trying to use CIUnit to test a model. I've gone back to basics, and tried to get the example "testSomeModel.php" to work, but it falls over when calling CIUnit_TestCase.dbfixt

I have an "_test" database group set up. Here is the contents of my database.php:

Code:
$env_used = 'default'; //where default would be the name of your development setting
if(defined('CIUnit_Version')){
  $env_used .= '_test';
}
$active_group = $env_used;
$active_record = TRUE;

$db['default_test']['hostname'] = "localhost";
$db['default_test']['username'] = "root";
$db['default_test']['password'] = "";
$db['default_test']['database'] = "product_test";
$db['default_test']['dbdriver'] = "mysql";
$db['default_test']['dbprefix'] = "";
$db['default_test']['pconnect'] = TRUE;
$db['default_test']['db_debug'] = TRUE;
$db['default_test']['cache_on'] = FALSE;
$db['default_test']['cachedir'] = "";
$db['default_test']['char_set'] = "utf8";
$db['default_test']['dbcollat'] = "utf8_general_ci";

I have 'database' set to autoload in config/autoload.php:

Code:
$autoload['libraries'] = array('database');

I also have a Product_model.php, and I have the fixtures ready to go. However, when running the test, I get this:

Code:
<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Trying to get property of non-object</p>
<p>Filename: fooStack/Fixture.php</p>
<p>Line Number: 36</p>

</div>

<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">

<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Trying to get property of non-object</p>
<p>Filename: fooStack/Fixture.php</p>
<p>Line Number: 37</p>

Looking at the load function in Fixture.php, it seems that $this->CI->db->database is empty. By adding $this->CI->load->database() to the top of the function, it seems to work:

Code:
function load($table, $fixt)
{    
       $this->CI = &get;_instance();
       $this->CI->load->database();
       ....

Does this suggest that fooLoader.php is not autoloading properly?

I'm using CI v1.7.1 and fooStack v0.15

Thanks in advance


Messages In This Thread
Problem with CIUnit fooLoader.php - by El Forum - 06-01-2009, 05:26 PM



Theme © iAndrew 2016 - Forum software by © MyBB