I am working on a test in phpunit and I am running on an issue. I have a public function in my class which I am trying to test. Based on the parameters passed in the method, a protected function in my test class will be asked once or twice. Currently I have a test to check that the return data is correct, but I would also like to ensure that the protected method Many times the correct number is being said.
I know that a fake object allows the function to calculate the number of times to be called, but it will also override the value returned by the protected function. I tried to use a counterfeit object with the "will" section, but it will return the recovery now, not the actual value of the protected method.
Example class
public function do_stuff ($ Runtus) {$ results = do_cool_stuff (); If ($ Runtus) {$ Result = 2 * DokuKO_StF (); } Returns $ results; } Secure function do_cool_stuff () {return2; }
In my trial, I want to check whether the do_cool_stuff () was called once or twice, but I still want to consider return values of both functions as equal. So that I can test them well in my unit test.
tl; I want to count the number of times a protected method in my test object (as you can with a duplicate object), but I still have all the methods to back my normal values in my test method (fake Not like the object).
The variables before using a global setting class
$ IAmDeclaredOutsideOfTheFunction;
Then use this to store counting and just check it after your work and classes.
Comments
Post a Comment