I did a lot of research on lastcraft.com but still could not find a solution.
Here is the gist of my class:
Now, I am testing a page controller that uses this model. I easily made a server stub for the dao (which returns another server stub). However when I make a mock object:PHP Code:class model {
var $dao; //data access
var $result; //database result object
function model(&$dao) { $this->dao =& $dao; }
function getInfo() { $this->result =& $this->dao->getInfo(); }
}
I just don't know how to make $model->result point to an object. I first just used the class itself until I realised I want to test a callCount for $model.PHP Code:Mock::generate('model');
$model =& new Mockmodel($this);
Also: because it is a mock, I get this error:
Fatal error: Call to a member function on a non-object in /.../lib/class.artcontroller.php on line 41
which isBut I think this is because I could not set the property.PHP Code:$model =& new MockModel($this);
So the question is, how can I set my mock $model->result as a reference to one of my server stubs?





Bookmarks