Menu

#26 Make is_a() work on mock objects

closed
1
2005-12-07
2005-11-25
No

Hi,

I like to check results form method calls that are
supposed to return an object with "is_a". However, when
I use a partial mocked object to return a mock object,
the mock-object extends SimpleMock, not the mock base
class.

Any easy way to implement that?

Jochen

Discussion

  • Marcus Baker

    Marcus Baker - 2005-11-28

    Logged In: YES
    user_id=695819

    Hi.

    Not in PHP4. The partial mock sactually do inherit from
    their original class of course, its the conventional mocks
    that do not. This is deliberate. The original classes may
    not have been written yet, or the constructors could have
    side effects, or other functionality may leak through via
    __get() type operations. I'd rather avoid the original base
    class for mocks.

    For PHP5 the mocks and partial mocks will implement any
    interfaces they find in theoriginal class. This allows them
    to work with type hinting and the like.

    I have to ask, should you really be checking return types
    with is_a()? Seem you are trying to emulate that other langauge.

    yours, Marcus

     
  • Marcus Baker

    Marcus Baker - 2005-11-28
    • labels: --> Unit test framework
    • priority: 5 --> 1
    • assigned_to: nobody --> lastcraft
     
  • Marcus Baker

    Marcus Baker - 2005-12-06

    Logged In: YES
    user_id=695819

    Hi.

    Just a nag message. Have I understood the problem correctly?

    yours, Marcus

     
  • Marcus Baker

    Marcus Baker - 2005-12-07
    • status: open --> closed
     
  • Marcus Baker

    Marcus Baker - 2005-12-07

    Logged In: YES
    user_id=695819

    Hi.

    I'd like to close this one for now, mainly because I don't
    understand it.

    yours, Marcus

     

Log in to post a comment.