Test-driving complex features with Laravel & Pest

Поделиться
HTML-код
  • Опубликовано: 12 ноя 2024

Комментарии • 13

  • @theceilidhboy
    @theceilidhboy 2 года назад +1

    Whenever I think the words "copy and paste" or hear another developer utter them, a big red alarm goes off in my mind 🚨So as soon as you said these fated words when going to make the ethereum asset, I was on alert and noticed you'd not set the ticker code to ETH and the name was still bitcoin. It's just as important for your tests to be DRY (Don't Repeat Yourself) as much as it is for your production code. Even when making a course, you fell foul of not applying this principle. So it was actually a good demonstration of why DRY is so important! Whenever thinking or hearing "copy and paste", it should be a trigger to make you refactor the code so you don't need to do that, e.g. write a helper method in the test to create an asset given its ticker code, name and price. It has the added benefit of making the test more readable ;)

    •  2 года назад +1

      Thanks for the comment Mike!
      In real life I’d probably resort to adding some predefined states on the AssetFactory class - as for repetition, more often than not replacing it with an abstraction makes things less obvious (this obviously depends on the situation).
      While recording a screencast it’s hard to keep track of everything, but I appreciate your comment - I’m sure it’ll be of help to lots of folks later!

    • @theceilidhboy
      @theceilidhboy 2 года назад

      @ could you give an example of an abstraction that would make the code less obvious in this situation of creating an asset?

  • @mavionogomuho8114
    @mavionogomuho8114 2 года назад +1

    Hi Mateus, what vscode extension are you using for laravel and php, thanks!

  • @udofiagodwin8194
    @udofiagodwin8194 2 года назад +1

    Excellent video, loved it! May I ask about your VS Code setup? Like, what extensions you use to get labelled arguments?

  • @JohnnyBigodes
    @JohnnyBigodes 3 года назад +1

    Good video, I really had fun watching it. 👍

  • @Niboros
    @Niboros 3 года назад

    Thanks for the awesome and informative video. Question tho; why do you like to use a static make() function instead of calling the class via the new keyword?

    •  3 года назад

      Thanks Robin!
      No specific reason. I was just doing things on the go and I thought I'd need to parse something for the constructor.

    • @mavionogomuho8114
      @mavionogomuho8114 2 года назад

      @ Hi Mateus, what vscode extension are you using for laravel and php, thanks!

  • @rabotherabo
    @rabotherabo 3 года назад +1

    Hey Mathew! Nice video. Can you help with your vscode setup for php laravel

    • @rabotherabo
      @rabotherabo 3 года назад +2

      I like the way the function arguments are labeled. This emulates phpstorm

    • @sousajep
      @sousajep 3 года назад +1

      @@rabotherabo I was going to ask the same thing!