This is the best video tutorial on the internet talking about mocks in PHP, just amazing. Thank you.
@GaryClarkeTech2 жыл бұрын
You're welcome. I'm glad you liked it!
@atuzon1986 Жыл бұрын
Agree with that
@sofascialistadankulamegado17812 жыл бұрын
I have adhd and have trouble with getting comfortable with tutorial styles and formats. Your video here is just bliss to me. Thank you thank you! Please don't stop making videos!
@GaryClarkeTech2 жыл бұрын
You're welcome. I'm glad that you enjoy my delivery!
@PaulKeeWong2 жыл бұрын
You explain the Mock in unittest that very easy understanding, you have reproduced difference use cases are very important to understand!! Thank you so much!
@GaryClarkeTech2 жыл бұрын
Welcome! Glad it was helpful!
@wpwilds Жыл бұрын
this is a very informative video, please don't stop making videos about php because your way of explaining is very good, god bless you
@GaryClarkeTech Жыл бұрын
Thanks Archaf..I appreciate the kind words. More to come soon!
@micasntna2 жыл бұрын
This is actually an amazing subject that I’m currently doing
@NeverCodeAlone2 жыл бұрын
Yes I also trz my best on it and hope that will work
@douglasfernando3845 Жыл бұрын
Successfully favorited video.
@obadaalzidi64527 ай бұрын
Thanks for this great video. So basically when we type hint the return type of the method that we're testing, and we call it on the mocked object we'll get null casted to that type.
@GaryClarkeTech7 ай бұрын
Exactly that
@samhk22222 жыл бұрын
i want to hit the like button for every test passed. Thanks, the best tutorial available on this subject.
@GaryClarkeTech2 жыл бұрын
Cheers Samuel..I really appreciate it. Hope you manage to use it in your projects!
@juanmadelaflor64062 жыл бұрын
Ty Gary!!
@GaryClarkeTech2 жыл бұрын
Welcome 👍
@NeverCodeAlone Жыл бұрын
Thx a lot for your work here.
@GaryClarkeTech Жыл бұрын
My pleasure!
@МухаметджинТимур2 жыл бұрын
Thanks for video. I have one question: how can i test the private or protected methods of class which return void?
@GaryClarkeTech2 жыл бұрын
There are a couple of ways... 1) Don't test them in isolation...only test the public API of the class 2) Use Reflection to make the method accessible
@МухаметджинТимур2 жыл бұрын
@@GaryClarkeTech thanks!!!
@NeverCodeAlone2 жыл бұрын
Makes this sense?
@parijke2 жыл бұрын
Nice Gary
@wisamalkhatib4020 Жыл бұрын
Hello would you please explain how to mock protect method and return specific value
@GaryClarkeTech Жыл бұрын
You can use Reflection to make methods public on the reflected object..BUT...I don't recommend doing that and recommend that you just test your public API. I cover this in the full course.
@wisamalkhatib4020 Жыл бұрын
@@GaryClarkeTech Hello Thank you for your quick reply in Reflection i get the method and set as pupblic method what should i do after that ? how can i say return true because this protect method calle an api to return bool value
@qkenkenu2 жыл бұрын
What you do @Gary Clarke - is defenatly amazing, I'm watching carefully tutorials where the key feature is to make "TESTS", and have no idea what the test are really needed for? Maded to check, is sometching that we anyway overriding each time will bring proper value? I dont know, are test are bringed to life just because to keep programers at work ???
@NoahNobody2 жыл бұрын
We have a PDO class at work that takes care of creating a PDO db instance. Is it possible to mock that?
@GaryClarkeTech2 жыл бұрын
Yeah..if you own it, I don't see why not. It won't work if it uses a static factory method to do this though...you can only stub instance methods.
@NeverCodeAlone2 жыл бұрын
Very nice video thx a lot
@markwilkinson276 Жыл бұрын
I have a trait which is used for handling HTTP requests. Is it possible to mock and test a trait? Really like your video and have been able to apply it so far for other areas of my app, but now I've hit a wall where I'm unsure how to handle traits. It's worth noting that I have a get() method which calls a protected makeRequest() method inside it - is it possible to test nested method calls? Again, can't think how this would work
@GaryClarkeTech Жыл бұрын
Yes..you can stub all of the public, non-static methods of your class, even if you are getting them from traits. Testing a nested protected method will require a bit of imagination...also consider refactoring for testability. Lots of that kinda stuff in the full course!
@lmartyn2 жыл бұрын
This is great. I know and use it now, but wish I had known sooner
@GaryClarkeTech2 жыл бұрын
Cheers Łukasz..bookmark it, it will come in handy as a reference 👍