Unit testing a class that needs a zf2 cache adapter

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Unit testing a class that needs a zf2 cache adapter

Julian Vidal
In ZF1 there used to be a BlackHole adapter that was a dummy implementation
meant for unit tests. I can't seem to find anything like that in ZF2 so I
created my own.

Since I might be looking in the wrong place or missing something, my
question is: how are people using ZF2 testing objects that need a zend
cache adapter?
Reply | Threaded
Open this post in threaded view
|

Re: Unit testing a class that needs a zf2 cache adapter

Julian Vidal
Ah yes.. the "beforeEach" methods. I've never really used them before but
they will come very handy with this problem.

Thanks!


On Sat, Mar 8, 2014 at 2:14 PM, Michael Gooden <[hidden email]>wrote:

> If the functionality you are testing does not directly involve the cache,
> and you just need an adequate mock, I find the memory (array) adapter works
> nicely.
>
> It has no dependencies and will always return what you place in it. You
> can also prime it with required data in your beforeEach statements.
>
>
> On 8 March 2014 00:55, Julian Vidal <[hidden email]> wrote:
>
>> In ZF1 there used to be a BlackHole adapter that was a dummy
>> implementation
>> meant for unit tests. I can't seem to find anything like that in ZF2 so I
>> created my own.
>>
>> Since I might be looking in the wrong place or missing something, my
>> question is: how are people using ZF2 testing objects that need a zend
>> cache adapter?
>>
>
>