php - trying to understand expects / with with phpunit -
From
:
// Set expectation for update () method // only To call one more string and 'some' as your parameter, call $ Inspector- & gt; Hopefully ($ this- & gt; Once ()) - & gt; Method ('Update') - & gt; With ($ this-> equalTo ('some')); If -> From () is considered to represent norms, which can be found in the $ this-> Is equalTo required? Which other methods can be used there and why would they like to? As it seems, this method of calling a fake update method is to be summarily written in a nutshell and send it to - & gt; ('Some') will be written better as .
And why -> Have to do ($ this-> one time ()) to ensure that the method is called only once? If you call fraud / method once, then how often can it be said several times?
If I do stros () then it is 5x times - this is being called once -> Hopefully ($ this-> one time ()) Just seems unnecessary.
You $ this-> requires arguments because you can specify the argument to define different protests. For the method you have -> in par Arguments () $ this-> With () is not, which means there is no logic or you do not care for them.
The one that I will use regularly $ is-> isInstanceOf () to check the type of object given to the mocked method is.
Similarly $ this-> There are a lot of ways to specify once () , how often it is called fake.
If you do not care how many times you use all just $ this-> Any () (Although this method will not be passed if it passes). I $ this- & gt; Absolutely () and $ this-> I use once () so that I can make sure that the method is often expected of me. To test cases of error, $ this-> Never () is especially useful, when the pleasure path is added to the test, so that I am specifying what steps should not be taken when something goes wrong.
A method is said once that the number seems a little bit to specify, but if you are writing data or a resource-intensive operation, you want to make sure that it Once done and not 5x which will affect the performance. By specifying once it is ensured that if a person revises your code and they re-tell the method that the test will fail.
Comments
Post a Comment