Is it possible to set properties on a Mock Object in Simpletest

Posted by JW on Stack Overflow See other posts from Stack Overflow or by JW
Published on 2010-04-23T10:49:43Z Indexed on 2010/04/23 10:53 UTC
Read the original article Hit count: 347

Filed under:
|
|
|

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.

Any advice welcome.

© Stack Overflow or respective owner

Related posts about simpletest

Related posts about mocking