#62 SimpleMock: allow reading out current call count (or reset)

open
nobody
None
5
2009-09-26
2009-09-26
daniel hahler
No

I have a base class EvoMockDbUnitTestCase, which creates a MockDB object in setup(), which can be used in testcases then.

The constructor of the DB class calls one of the mocked methods ("query") however already.

So I'd be able to reset the call counts after having setup the mocked object, so that the test cases expectations match.

An alternative approach might be, that a call to expectCallCount() would reset the counters ($call_counts).
This would however interfere for sure with expectAt.

Therefore I think a clean interface to reset any related collected data is required.

Discussion

  • daniel hahler
    daniel hahler
    2009-12-07

    I've found that there's a getCallCount method, which I could use.
    However, by default $mock is not accessible/private.

    In createSubclassCode, the $mock property gets exported as public, in extendClassCode however it does not. I think this should be consistend and public in the other case, too.
    Provided that, I can use $this->MockDB->mock->getCallCount('query') to get the number of invocations of this method.

     
  • daniel hahler
    daniel hahler
    2009-12-07

    Patch against SVN trunk