[eluser]jlester[/eluser]
I am writing a test suite for an application and have model functions that look like:
Code:
function model_function() {
$var1 = $this->input->post('var1');
$var2 = $this->input->post('var2');
...
}
What I would like to do (and what I have tried) is to write a test function that looks like this:
Code:
function test_controller() {
$this->load->model('my_model');
$_POST['var1'] = 'value1';
$_POST['var2'] = 'value2';
$ret = $this->my_model->model_function();
$this->_assert_true($ret);
}
So, in words, I'd like to populate the $_POST variable then call a model function that will read the values in $_POST using $this->input->post(). This however does not seem to work. input->post() returns FALSE for everything.
Is this a case where CI is setting an internal variable when it is initialized and used by input->post() such that setting $_POST values after CI has initialized is pointless? If this is not the case, what am I missing? It seems like my approach ought to work.
Thank you.