I normally use getter and setter methods on my objects and I am fine with testing them as mock objects in SimpleTest by manipulating them with code like:
Mock::generate('MyObj');
$MockMyObj->setReturnValue('getPropName', 'value')
However, I have recently started to use magic interceptors (__set() __get()) and access properties like so:
$MyObj->propName = 'blah';
But I am having difficulty making a mock object have a particular property accessed by using that technique.
So is there some special way of setting properties on MockObjects.
I have tried doing:
$MockMyObj->propName = 'test Value';
but this does not seem to work. Not sure if it is my test Subject, Mock, magic Interceptors, or SimpleTest that is causing the property to be unaccessable.
So, in summary:
I can mock-up methods on my mock objects but i am having trouble mocking-up class properties of mock objects. Is it possible to set properties on a Mock Object in Simpletest?
Any advice welcome.
UPDATE:
- i had a typo in my code which was obscuring my view of this new territory. so
- it is possible to set the properties
- i will add the answer below