in reply to Re^5: ISA but no farther?
in thread ISA but no farther?

Is ->mocks a standard method name? I'd use it if it were.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^7: ISA but no farther?
by jhourcle (Prior) on Jul 20, 2006 at 19:43 UTC

    I have no idea. I've never played with MockObject or anything else similar.

    It was more an idea to specify an API, so that you provide a way for people to bypass your checks.

    In looking, it seems that Test::MockObject gets named through fake_module, and I don't see that it actually keeps track of the class that it's mocking.

    I'm still not sure exactly what the overall purpose of this is, so I don't know if just providing a documented way for people to override the check is sufficient. (you could also submit the necessary patches to chromatic for Test::MockObject, so it's been implemented somewhere)

      Test::MockObject doesn't keep track of the class; you'd have to add a mocks method to it and call ->mocks('OP') in your test script and ->mocks() eq 'OP' in the actual module.

      Test::MockObject::Extends does keep track, in @{ref($obj)."::ISA"}, but you'd have to say ref($obj) =~ /^T::MO::E::/ to detect a mock object.

      If people really do need to check for non-subclassed classes, both Test::MockObject types ought to be fixed to make this painless. But I still don't see why that would be necessary.