Test Driven Laravel - e01 - Introduction, PHPUnit Setup & Books Test Part 1

Поделиться
HTML-код
  • Опубликовано: 15 ноя 2024
  • In this lesson, we are starting a project from scratch including setting up sqlite for testing, initializing Git and writing our first tests to add Books into our library.
    For the best experience, follow along in our interactive school at www.coderstape...
    DigitalOcean Referral
    m.do.co/c/7dce...
    Resources
    Course Source Code
    github.com/cod...
    Hit us up on Twitter with any questions or comments @codertape ( / coderstape )
    About This Course
    We are tackling a brand new series to showcase a real-world workflow that you may adapt to your liking. We will be building a library management software for our local library that will include the ability to checkout books, reserve books and much more. We will be doing this through the TDD methodology, come along as we dissect Test Driven Laravel Development.

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

  • @bulent2435
    @bulent2435 3 года назад +30

    I hope you are alright and doing great. I don't know why you stopped posting new videos. You are an amazing teacher and I think your channel was about to become a huge one.

    • @antonioanerao
      @antonioanerao 2 года назад +2

      He's really a good teacher. Do you have any news about him?

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

      I totally agree! This the best Laravel teacher on the internet.. i learned a lot from him. I hope he's coming back for some new fresh Laravel 9 tutorials 😇

  • @Stoney_Eagle
    @Stoney_Eagle 5 лет назад +74

    There is no one on RUclips that goes as deep into a piece of software as you do.
    Holy moly you're on a roll.

    • @bombersycx4777
      @bombersycx4777 5 лет назад +2

      agree

    • @williamstickles6062
      @williamstickles6062 4 года назад +1

      I agree. It is tough to get a decent TDD Tutorial. Thanks. Yours was informative and easy to follow.

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

      @Ricky Kian I watch them on my own platform called NoMercy TV 😉 it's still a wip tho.

  • @nameusername2741
    @nameusername2741 4 года назад

    یکی از بهترین مدرسان کدنویسی شما هستید....
    یه نکاتی گفتید که اصن من ندیده بودم....
    رایگان این همه نکته ی طلایی رو ارائه دادید....
    بی نهایت تشکر بخاطر این دوره و چند دوره ی api که اونم فوق العاده کاربردی بود.

  • @asim-gandu-phenchod
    @asim-gandu-phenchod 2 года назад

    1 word. PERFECTION. Thanks a lot victor

  • @daviddeleon3411
    @daviddeleon3411 5 лет назад +3

    I never think that someday i am going to learn phpunit because this is such an advance part in php, but now I'm here learning this! Thank you Sir Victor for your modern teaching style! It helps me so much in my path! It feels like I am a real programmer lol.

    • @CodersTape
      @CodersTape  5 лет назад +1

      it just takes one day to decide to start testing your applications and then you'll never go back

    • @daviddeleon3411
      @daviddeleon3411 5 лет назад

      @@CodersTape Yes Sir copy :)

  • @creative-commons-videos
    @creative-commons-videos 2 года назад

    your content is exactly equal as Laracasts videos that i have been watching since years

  • @simonguitarjackson
    @simonguitarjackson 4 года назад

    Seems to me this should be the first thing learnt by anyone approaching any form of development. Ta muchly!

  • @talhamasood6165
    @talhamasood6165 4 года назад +2

    Dude you are really doing amazing job indirectly you’re enhancing developers and the future of development! Thanks man!
    Very few good people like you.

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

      I know I am pretty off topic but do anybody know of a good place to watch newly released series online?

  • @fullstack5008
    @fullstack5008 5 лет назад +3

    Thanks 🙏🙇🙏🙇🙏🙇🙏🙇 for starting this series

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

    tank you Mr. Victor, you helped me a lot

  • @dmdk8301
    @dmdk8301 5 лет назад +5

    First youtuber i trust, i wait, and like before watching. Keep tutor-coding, Victor. You,re great!

  • @sumonchandrashil8406
    @sumonchandrashil8406 4 года назад

    Thank you boss.
    I'm expecting this series from you. As you explanation power is very strong.

  • @mattiatoselli5263
    @mattiatoselli5263 4 года назад +1

    You are very great man, really! your way to explain things, the code you write, simply amazing! Cheers from Italy.

  • @raphaelandrade555
    @raphaelandrade555 5 лет назад

    Best series about TDD with Laravel, no doubt!!!

  • @Laflamablanca969
    @Laflamablanca969 4 года назад

    Awesome tutorial. The best one I've managed to find on RUclips. Cheers

  • @adam192021
    @adam192021 5 лет назад +8

    the BEST as always!

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

    I am following this course

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

    i'm envious on how he is really efficient in using PHPstorm. with method extraction, inline, etc shortcuts.

  • @robeeeeen
    @robeeeeen 4 года назад

    This is call Test Driven Development!!

  • @djamelbenali6883
    @djamelbenali6883 5 лет назад +2

    Amazing video.

  • @marcosdonadio868
    @marcosdonadio868 5 лет назад +2

    I love your channel. You do not have as many followers as you deserve, but keep up the good work ... definitely better than many paid courses.
    Greetings from Argentina

  • @anisdhouieb9918
    @anisdhouieb9918 5 лет назад +2

    I was waiting for this series, thanks Man !!!

  • @Anonymous-jd3zc
    @Anonymous-jd3zc 5 лет назад +1

    Very informative videos bro, I love how you explain the reason behind everything you do, and why it's not done differently, most tutorials are just 'do this.. do this.. do this' and they never tell why. This is a great series, I hope you continue this for a very long time.

  • @itiskawsar
    @itiskawsar 9 месяцев назад

    We miss you, hope you will be back soon to us :)🙂

  • @dnevnick
    @dnevnick 5 лет назад +7

    My solution for creation alias "pf" on Windows:
    Create pf.bat in project directory with this code inside:
    @echo off
    cls
    vendor\bin\phpunit --filter %1
    Now you can run in cmd
    pf a_book_can_be_added_to_the_library
    And dont forget about /** @test */ before public function a_book_can_be_added_to_the_library()

    • @jumalkull
      @jumalkull 4 года назад

      phpstorm can do unit test comand instantly

    • @YONS_
      @YONS_ 4 года назад

      Or just use a better console, like Cmder, Git Bash...

    • @georgebarlowr
      @georgebarlowr 4 года назад

      or just use jetbrains intergration of phpunit testing

    • @AquiEnAguas
      @AquiEnAguas 4 года назад

      You are amazing

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

    How awesome is that!

  • @irfanullahshakir3568
    @irfanullahshakir3568 4 года назад

    Very helpful, please don't stop to share such stuff. Subscribed ;)

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

    Great tutorial. Thank you.

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

    Thank you so much Bro!. This was very informative and helpful.

  • @ahmedhdeawy
    @ahmedhdeawy 4 года назад

    Thanks man for your effort and time

  • @morleytechtv7749
    @morleytechtv7749 5 лет назад +2

    Hey dude thanks a lot I learn lot of things in your videos.

  • @mavbcn1790
    @mavbcn1790 5 лет назад +2

    Thanks so much for your videos, are great!

  • @wcorreia100
    @wcorreia100 5 лет назад

    Hi, I have been going through a few episodes of your various series and i find the awesome !. I love the way you put across the various concepts. Way to go !!! Thank you.

  • @jumalkull
    @jumalkull 4 года назад

    І нарешті це несамовите відчуття радості, коли твій перший юніт тест пройшов!!!)))

  • @renarsdilevka6573
    @renarsdilevka6573 4 года назад

    Very inspiring, but for update i would suggest to use PUT and stick to modern development with RESTful requests :) Having said that you used PATCH later, that will work as you are partly updating.

  • @scibuff
    @scibuff 4 года назад

    Your tutorials are awesome but it would be really great if you could always show the keyboard shortcuts when you're using them (I realize that would affect only new videos but it's definitely something I'd like to see)

  • @dreikojhon
    @dreikojhon 4 года назад +1

    What about if I want to test an API resource? Which url's I've to use?

  • @Robert-ov1wi
    @Robert-ov1wi 5 лет назад

    Great video.

  • @floydapungan5359
    @floydapungan5359 4 года назад

    Just wow man

  • @noorahmed5115
    @noorahmed5115 4 года назад

    How awesome is that!!!!!

  • @dgloria
    @dgloria Год назад

    Hi, I'm not sure if you read this, if I don't want the tables to be truncated, because I have a working app, how can I reset only the one table I have created now, and leave the rest as is? Also if I add tests later, when my table is in constant use, I need the same: the data that is in the table shouldn't be deleted. Thank you

  • @bernardchisumo4054
    @bernardchisumo4054 4 года назад

    Hi Victor, before I start the course, how do u set up the UI of item2 terminal?

  • @johnstorm589
    @johnstorm589 4 года назад

    thank you!

  • @geeksy2278
    @geeksy2278 5 лет назад

    This is so awesome! Thank you

  • @dgloria
    @dgloria Год назад

    I've got a CSRF token mismatch error when I test the update method in postman, and every test I run creates a new table entry in my database table.

  • @gideaoferreira8236
    @gideaoferreira8236 5 лет назад

    Great tutor!.

  • @lordgodgiven
    @lordgodgiven 5 лет назад +1

    Hello,
    Thanks for the test driven developpement tutoriel, l'd like to know why you don't use Form Requests to extract validation logic in another class? instead of to have a protected methode to validate data in a controller.
    Great job

    • @CodersTape
      @CodersTape  5 лет назад +1

      I like to save those extractions to when it’s absolutely necessary. It adds a lot of technical debt to an otherwise very simple protected method. I just don’t believe a 2 field form requires a class just for validation. I like the simplest route unless it’s absolutely necessary and then you’ll get the code smell and require a refactor.

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

    can you do a video on how to setup phpstorm specifically for laravel (plugins, settings, or other hacks)

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

    What are your suggestions for the newcomers?

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

    This is a good video. I have one question though, even using TDD, would it be acceptable to create resource controllers so that the routes are already registered? Or, is it better to use the red, green, refactor system and work your way to developing said resource controller. As a shortcut, Artisan can make your model, migration, resource controller, seeders, and factories with one command. When it comes to TDD, especially within laravel, should these "shortcuts" be ignored and developed as you create tests?

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

      no, u should follow best practice at all and what u said is the best solutions

  • @hanieasemi
    @hanieasemi 4 года назад

    I love it, thanks

  • @linguapharm
    @linguapharm 5 лет назад +2

    Waiting Complete Online Laravel E commerce Development Series (Product - Category - Subcategory ), with all its packages

    • @CodersTape
      @CodersTape  5 лет назад

      We might tackle that some day

    • @linguapharm
      @linguapharm 5 лет назад

      @@CodersTape What you recommend from Open sources available?

    • @juliaof.kataleko7595
      @juliaof.kataleko7595 4 года назад +1

      I'm finishing a ecommerce with laravel, with products ratings and discounts..

  • @ghostza1209
    @ghostza1209 5 лет назад

    Thank you so much!!!

  • @mojtababarari7749
    @mojtababarari7749 4 года назад

    Hi, Victor. Real thumbs up!! watched your Full Course and these TDD. Perfect. Thanks a lot!!
    but i have 2 problem.
    first $this->withoutExceptionHandling() give me undefind error
    second how set up mysql for testing.
    btw i'm on windows and laravel 6.*

  • @tkouleris
    @tkouleris 5 лет назад

    Great Video. A quick question! Could we use Form Request for the validation instead of the protected method or are Form Requests a different concept?

  • @guilhermes9272
    @guilhermes9272 5 лет назад

    In some point of this course, you'll explain or use Dusk?

  •  4 года назад

    Hi. Thank you for this great tutorial! I have an error, somebody can help me what is the solution? Method Illuminate\Http\Response::assertEquals does not exist. (Laravel 6.17, PHPUnit 8.5.2)

  • @janvier3871
    @janvier3871 4 года назад +1

    Man you've made an understandable video but I'm stuck Sir how do you use pf test-function-name
    I'm stuck please help
    My OS is windows 10

  • @MrFranciscoooooo
    @MrFranciscoooooo 4 года назад

    couldn't you do an env.testing?? sinf in phpunit.xml the app_env is testing?

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

    How did you open phpstorm by just typing "phpstorm"? And is it possible on a windows machine? :)

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

      press the windows key and type phpstorm

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

    why do you write those test in Feature folder instead of Unit folder?

  • @Skaknky0815
    @Skaknky0815 4 года назад

    Hi thanks for the nice Tutorials,
    but a POST should return a 201 status for creating a new dataset and the $this->assertDatabaseHas(..., [...]); method its a bit cleaner then check the count .

  • @aaryanshrestha7559
    @aaryanshrestha7559 5 лет назад +1

    Hi, I am new to this testing thing, I followed all the steps properly but when testing show no tests executed. I run the command :- phpunit --filter a_book_can_be_added_to_library ?? Am I doing something wrong??

    • @CodersTape
      @CodersTape  5 лет назад

      Before the public function a_book_can_be_added, you must have /** @test */
      github.com/coderstape/library/blob/51acb0edb44f583771dbd9ea786cec2571c7ee6c/tests/Feature/BookManagementTest.php#L14

    • @SandmanGeek
      @SandmanGeek 5 лет назад +2

      You need to run phpunit from vendor/bin/ directory and then pass in the method name
      i.e.
      ./vendor/bin/phpunit --filter a_book_can_be_added

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

    After searching for a while, I come to understanding that $this->withoutExceptionHandling() should not be used when we test the case which we want it to be "wrong" such as request validation, unauthentication, etc... else it will throw out exception and will not reach the assertion statement below...

  • @dugalman
    @dugalman Год назад

    What is your terminal, I like to install

  • @DodaGarcia
    @DodaGarcia 4 года назад +1

    I spent the whole video being like "jesus this sounds like a LOT of work for very little benefit, what's even the point of testing things before I write them"
    Then at the 25 minute mark when he started refactoring the code knowing from the tests it wouldn't break anything, I suddenly went back to all the nightmarish times I had to look for what part of my refactoring broke something and everything clicked.

  • @Gonza2432
    @Gonza2432 5 лет назад +2

    ❤️❤️❤️❤️

  • @TigaWarnaToko
    @TigaWarnaToko 4 года назад

    what is laravel version that you used ?

  • @ممدو-ص1ث
    @ممدو-ص1ث 3 года назад

    great

  • @adamkozowski1994
    @adamkozowski1994 4 года назад

    I work with laravel 6. There is a problem because phpunit.xml data is not read. That is why my APP_ENV is local instead of testing. Any solution?

    • @adamkozowski1994
      @adamkozowski1994 4 года назад +1

      aww, that was just caching.. php artisan config:clear

  • @calibroguy3247
    @calibroguy3247 5 лет назад

    any plans of Docker, kubernates with laravel?

    • @CodersTape
      @CodersTape  5 лет назад +1

      Not at this time. But maybe in the future

  • @XORknight
    @XORknight 5 лет назад

    Thank you for this great tutorial, for those who I have not followed your previous course it's probably worth covering OR those who are having issues:
    First of all, if you get "No tests executed!", set your phpunit path accordingly. Try: ./vendor/bin/phpunit --filter
    secondly, install SQLITE if not done previously, see: ruclips.net/video/wXEZZ2JT3-k/видео.html&vl=en
    and finally, create database.sqlite in database folder or see stackoverflow.com/questions/31132270/set-sqlite-as-database-for-unit-testing-in-laravel-5-1 . this was quickly shown in the video but not explained.
    Once again, thank you for making these tutorials.

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

    if any one face this problem Response status code [419] does not match expected 200 status code. just use this trait use WithoutMiddleware; in the test class

  • @GiovanniPutignano71
    @GiovanniPutignano71 5 лет назад +2

    I can't find assertCount in Laravel documentation

    • @CodersTape
      @CodersTape  5 лет назад +2

      That’s correct. assertCount is a phpunit method. You can check it out here
      phpunit.readthedocs.io/en/7.4/assertions.html
      Search for assertCount()

    • @NathanBudd
      @NathanBudd 5 лет назад +1

      phpunit.readthedocs.io/en/8.1/assertions.html#assertcount

  • @vnadino7658
    @vnadino7658 4 года назад

    I met a problem $response->assertOk();
    error show: BadMethodCallException: Method assertOk does not exist
    help me!

  • @sherwindejesus
    @sherwindejesus 5 лет назад

    I like your terminal theme/colors. how can i do that?

    • @ashirafjabery8685
      @ashirafjabery8685 5 лет назад

      check this out github.com/robbyrussell/oh-my-zsh/wiki/Themes

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

    🤯🤯🤯🤯🤯🤯🤯
    Where are you bro!!???

  • @prezire
    @prezire 5 лет назад

    This is all and well until the client demands that you finish the entire application within 30mins. Hope you have a tutorial on how to ask the client for more time to perform TDD.

    • @CodersTape
      @CodersTape  4 года назад

      Nope but I am certainly interested if you find one! :)

    • @prezire
      @prezire 4 года назад +1

      @@CodersTape Sadly i haven't. Been searching for thousands of years that applies to all project and client types, but there's none. But all in all, very nice tutorials! Keep it up.

    • @CorporalPoon
      @CorporalPoon 4 года назад

      if a client wants a custom application in "30 mins" then I suggest you drop that client immediately :)

    • @CodersTape
      @CodersTape  4 года назад

      😭 I’ve met plenty of clients with bigger expectations than wallets

  • @delvinduel189
    @delvinduel189 4 года назад

    I get the following error when I use 'alias pf', alias : This command cannot find a matching alias because an alias
    with the name 'pf' does not exist. whats the solution please help..

    • @delvinduel189
      @delvinduel189 4 года назад

      I got it..I didnt use vendor\bin\phpunit

    • @janvier3871
      @janvier3871 4 года назад

      1) Create pf.bat in project directory
      2) writes the following contents in pf.bat
      @echo off
      cls
      vendor\bin\phpunit\ --filter %1
      3) Run this command in terminal
      .\pf test-function-name ex:a_title_is_required
      Don't forget to write /** @test */ before test name

  • @vaibhavsinghal3798
    @vaibhavsinghal3798 5 лет назад

    How can we create an alias that you've shown in the video like "alias pf", can anyone guide me?

    • @CodersTape
      @CodersTape  5 лет назад

      jonsuh.com/blog/bash-command-line-shortcuts/

    • @SandmanGeek
      @SandmanGeek 5 лет назад

      Simple
      alias pf='clear && phpunit --filter'
      Now you can just type
      pf a_book_can_be_added
      and there you go...

  • @Salman59521
    @Salman59521 5 лет назад

    How to perform this with MySQL?
    I tried to use MySQL instead of SQLite but it always returns
    No tests executed!
    Configuration read from C:\xampp\htdocs\learningTDD\phpunit.xml

    • @CodersTape
      @CodersTape  5 лет назад

      Make sure that you have the /** @test */ notation before every test.

    • @overlordmarvel12
      @overlordmarvel12 5 лет назад

      @@CodersTape i m having this error, after running phpunit --filter ....
      PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 277
      Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 277PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 285
      Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\php\pear\PHPUnit\TextUI\Command.php on line 285PHPUnit 3.7.21 by Sebastian Bergmann.
      Configuration read from C:\Users\dell\Desktop\Dashboard\phpunit.xml

    • @SandmanGeek
      @SandmanGeek 5 лет назад +1

      @@overlordmarvel12
      You need to run phpunit from vendor/bin/ directory and then pass in the method name
      i.e.
      ./vendor/bin/phpunit --filter a_book_can_be_added

  • @offerszonebr
    @offerszonebr 5 лет назад

    Sir, Please make a video of custom login using laravel.
    And also make a video about laravel model relationship deeply.
    Please please please please sir.
    🙏🙏🙏🙏🙏🙏

    • @feranmiafrica9528
      @feranmiafrica9528 5 лет назад

      Watch he's Instagram clone video he covered it there

  • @techietoons
    @techietoons 3 месяца назад

    Where have you gone. Did something happened to you?. You stopped posting all of a sudden. Not even a community note...

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

    you leave RUclips?

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

    This will not work with laravel 8 outdated.