Closed kriskd closed 2 years ago
I'd be tempted to mock the Writer and just put it into the class, rather than trying to overload the method return. If the getWriter()
returns a Writer instance, I presume if you set a Mock into the class the method will return that anyway.
I'm using version 3.8.1 of this plugin because my project is on Cake 3.4.14.
I'm having difficulty mocking a method in the behavior for my controller (integration test).
Here is how I'm adding the behavior to my Table Class:
And my mock in my test is setup like this:
The result is
getWriter
is not getting mocked as I would expect. ThegetWriter
method is reached and obviously not returning my mocked$Writer
.However, if I make the key in my
addBehavior
options anything butfile
, then the mock works. So change it to:The mock is now respected and the test passes but of course the upload won't work because the column name in my table is
file
, notfoo
.Suggestions on what I may be doing wrong?