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

That's nasty. I'd just be requiring that objects be always mocked through Test::MockObject instead of some other kind of proxy or whatever.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

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

    As a variation on ysth's suggestion, you could require that the mocking class implement the 'mocks' method:

    ref($obj) eq 'OP' || $obj->can('mocks') && $obj->mocks('OP')

    Of course, if 'mocks' it handled through AUTOLOAD, this will fail.

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

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

        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)