I am having troubles to test one of my methods because it uses a vendor class with no model.
Well, the thing is that i want that method to return me what i want.
I have been told that mocking a method is to make it return what i want.
For example, when i call “foo()” method i want it to return me true always.
How can i do it? At CakePHP cookbook i can find this:
$Posts = $this->generate('Posts', array(
'methods' => array(
'isAuthorized'
),
'models' => array(
'Post' => array('save')
),
'components' => array(
'RequestHandler' => array('isPut'),
'Email' => array('send'),
'Session'
)
));
So i guess i should have to use the fist option: method
But… how to make it return what i want?
Thanks.
Refer to the answer I gave you in this question: How can i test an Add function on CakePHP2.0
For more information on mocking: http://www.phpunit.de/manual/3.0/en/mock-objects.html