Symfony 5 Test Driven Development (TDD) Tutorial

  Рет қаралды 46,855

Gary Clarke

Gary Clarke

Күн бұрын

Пікірлер
@thijsdewaard7567
@thijsdewaard7567 2 жыл бұрын
Hi Gary, sick shit! but is the api still working? I'm not able to navigate to the page of the api and not able to fetch any data.. getting a 403 response gr thijs
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
I've not checked recently but no one else has mentioned it. 403 means there's some kind of problem with your creds. You set up auth the same way as me?
@thijsdew1988
@thijsdew1988 2 жыл бұрын
@@GaryClarkeTech nope used my own, thinks it does't work anymore cuz i am able to use other api's
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
@@thijsdew1988 ok..thanks for letting me know. I'll check it out when I get the chance.
@MrSonicastra
@MrSonicastra 2 жыл бұрын
I got the same 403 forbidden, but i had to add a creditcard with a basic plan $0/month but only 250 requests.
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
@@MrSonicastra Thanks for solving this. I'll pin this thread 🤝
@DaviMartins99
@DaviMartins99 Жыл бұрын
One of the best TDD videos i've seen. Great content, mate!
@GaryClarkeTech
@GaryClarkeTech Жыл бұрын
Thanks a lot..I appreciate it!
@velvetrev707
@velvetrev707 2 жыл бұрын
Finally some Symfony videos that really worth to watch...great work man
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Glad you liked it!
@Rositukasss
@Rositukasss 3 жыл бұрын
As for a fresh graduate programmer this course helped me A LOT while solving the technical task required for job application. Thank you, learned so many new things while double watching this course
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
That's wonderful Rosita..I'm glad I was able to help and I hope you get the job!
@ahmedslink
@ahmedslink 3 жыл бұрын
Thanks for the very good tutorial In minute 15:41 command should be > `symfony console make:command app:refresh-stock-profile`
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Thanks Ahmed 👍
@130FMB
@130FMB 3 жыл бұрын
Amazing demo and great TDD mentoring! This is great content 👏👏👏 I'd love to see more 🤞 Thanks for your work :)
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Thanks Léo...I appreciate it 👍 I release a new recording every week.
@ivansavchenco5636
@ivansavchenco5636 3 жыл бұрын
Who the hell has disliked this video??))))) Good job lots of thanks!s)
@makomweb
@makomweb 3 жыл бұрын
Thank you so much for this high quality content. I learned so much from this video and appreciate how you explained all the details. After I failed with Symfony 5.2 - I had a dependency version conflict with DAMA/doctrine ... - I was able to recode everything with Symfony 5.3 nicely.
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Nice one Martin...good man 👊
@walterdiaz2003
@walterdiaz2003 2 жыл бұрын
I've been using Symfony and Spring framework and if you learn one you learn the other one without much effort. Both are great frameworks.
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Thanks for sharing!
@walterdiaz2003
@walterdiaz2003 2 жыл бұрын
@@GaryClarkeTech thanks for your content.
@soufianelamnizeh
@soufianelamnizeh 2 жыл бұрын
Amazing, i appreciate your efforts to show us all this stuff in one video, thank you again
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Welcome Soufiane...so nice of you
@vladyslavsvizinskyi4558
@vladyslavsvizinskyi4558 Жыл бұрын
Thx Gary, as always your turorials give a lot the usefull stuf and configurations. This one is great!!! ;)
@GaryClarkeTech
@GaryClarkeTech Жыл бұрын
Thanks a lot. I appreciate it!
@onparallel7953
@onparallel7953 3 жыл бұрын
WOW !! this is amazing !! Thank You Gary !!
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Thank you..I appreciate it!
@dam0ne
@dam0ne 3 жыл бұрын
Awesome content Gary!! Will follow it and enjoy it this weekend!
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Thanks Jorge...enjoy!
@dam0ne
@dam0ne 3 жыл бұрын
@@GaryClarkeTech never used sqlite before and was getting a DriverException from Doctrine when running the first test, just sharing in case someone encounters the same problem. Fixed it by installing sqlite and uncommenting the sqlite lines in /etc/php/php.ini Thinking that maybe starting the tutorials by creating the docker containers in which to work would eliminate this kind of local dependency issues for viewers.
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Cheers Jorge..good tip. Glad you fixed it!
@RastislavBostik
@RastislavBostik 5 ай бұрын
amazing work Gary, thank you so much!
@GaryClarkeTech
@GaryClarkeTech 5 ай бұрын
You bet!
@bikalbasnet
@bikalbasnet 2 жыл бұрын
Thanks Gary, very nicely done.
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Very welcome Bikal, cheers
@b1olenyleny449
@b1olenyleny449 3 жыл бұрын
Thank you for your premium content.
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
You're welcome 👍
@KwabenaAfreh
@KwabenaAfreh 2 жыл бұрын
This is very helpful. Simple and a good test strategy
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Glad it was helpful!
@AndrewErwin73
@AndrewErwin73 2 жыл бұрын
In the price tests, you should test for assertIsNumeric because sometimes it sends back whole dollar amounts with no cents (and it does't display xx.00) when that happens, the test will fail.
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Cheers Andrew..well spotted
@miguelangeljordan4205
@miguelangeljordan4205 2 жыл бұрын
I'm traying to do it, but in the minute 13:17 get this error: 1) App\Tests\StockTest::a_stock_record_can_be_created_in_the_database Doctrine\ORM\Mapping\MappingException: Class "App\Entity\Stock" is not a valid entity or mapped super class. Some idea?
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
This will possibly help.. stackoverflow.com/questions/7820597/class-xxx-is-not-a-valid-entity-or-mapped-super-class-after-moving-the-class-i
@azbrestjohn110
@azbrestjohn110 Жыл бұрын
Wow ! I didn't think that in-memory DB can be used for unit tests , thank you ! It indeed makes sense, because these DB are temporary, and each test have its own DB... This will avoid me to use mock objects to use the EntityManager then 🙂!
@GaryClarkeTech
@GaryClarkeTech Жыл бұрын
Yes, although you can do the same with non in-memory. In memory is just faster for this this kinda thing
@Immortal-pu8gr
@Immortal-pu8gr 8 ай бұрын
Thank you! Gary
@GaryClarkeTech
@GaryClarkeTech 8 ай бұрын
Thanks for watching!
@VipapkStudiosOfficial
@VipapkStudiosOfficial 3 жыл бұрын
Awesome! Thanks Gary! :)
@SurpassPh
@SurpassPh 2 жыл бұрын
Hey Gary, thanks for the video. I am using symfony v6.2 and so far followed everything. in 13:10 of the video I get this error: There was 1 error: 1) App\Tests\StockTest::a_stock_record_can_be_created_in_db Error: Call to a member function persist() on null C:\wamp64\www\phpunit\tests\StockTest.php:45 Any idea what might be the cause?
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Yes..looks like you don't have an entity manager...you're getting null instead. Dump out your entity manager using dd() and see what you get then work backwards to figure out where you went wrong with it.
@leroyjenkins1911
@leroyjenkins1911 3 жыл бұрын
Thank you. Very useful.
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Glad to hear that!
@CaimAstraea
@CaimAstraea 3 жыл бұрын
Hmm I have a stupid question maybe :) Should tests belong in the main repo ? On the dev branch ? Or just keep them locally on my machine ? Because eventually what's on the dev branch will eventually be merged in the production and deployed.
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
No such thing as a stupid question. Yes, tests belong in the main repo...they are as important as the code itself.
@SnGrg
@SnGrg 2 ай бұрын
Yes it is a great question. It belongs to the main/master branch of your project repo because in an agile team/environment you probably will have a Continuous development/continuous deployment tool with Pipelines where you can define to run the test before it gets deployed because if someone managed to push some breaking code then the automated phpunit test will identify the fail points and pipeline will not deploy the code to the more vital production environments.
@webdev723
@webdev723 2 жыл бұрын
Great stuff
@krzysztofmichalski7325
@krzysztofmichalski7325 3 жыл бұрын
Hi Gary, great course, thanks a lot! I have created services_test.yaml with fake implementation but functional test is still using Amazon Api instead of fake implementation. I'm using Symfony 5.3. In your video you are using Symfony 5.2. Are there any changes in naming convention for yaml with tesing config?
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Hi Krzysztof...no, config/services_test.yaml is still a thing in S5.3. You'll need to retrace your steps. Is your fake implementing YahooFinanceApiClientInterface?
@krzysztofmichalski7325
@krzysztofmichalski7325 3 жыл бұрын
@@GaryClarkeTech thanks for the answer. It started to work on my machine after adding adding response types. Maybe it was the case of cache?
@jordondavidson3405
@jordondavidson3405 3 жыл бұрын
@@krzysztofmichalski7325 I had the exact same issue. Running ./bin/console cache:clear --env=test fixed me right up.
@MrSonicastra
@MrSonicastra 2 жыл бұрын
Thanks for the video Gary, but i got an issue at 42min in the video. I want to test YahooFinanceApiClientTest in integration folder, and i got 'Undefined property: stdClass::$price' i think its due this line off code: $stockProfile = json_decode($response->getContent())->price; any idea's? Thx
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Trying dumping out the content like so.. dd($response->getContent()); What do you see?
@MrSonicastra
@MrSonicastra 2 жыл бұрын
@@GaryClarkeTech I got this: "{"total":76,"offset":0,"results":[{"exchangeCode":"AMS"},{"exchangeCode":"ASE"},{"exchangeCode":"ASX"},{"exchangeCode":"ATH"},{"exchangeCode":"BER"},{"exchangeCode":"BRU"},{"exchangeCode":"BSE"},{"exchangeCode":"BTS"},{"exchangeCode ":"BUD"},{"exchangeCode":"BUE"},{"exchangeCode":"CAI"},{"exchangeCode":"CCS"},{"exchangeCode":"CNQ"},{"exchangeCode":"CPH"},{"exchangeCode":"CSE"},{"exchangeCode":"DOH"},{"exchangeCode":"DUS"},{"exchangeCode":"EBS"},{"exchangeCode":" ENX"},{"exchangeCode":"FKA"},{"exchangeCode":"FRA"},{"exchangeCode":"GER"},{"exchangeCode":"HAM"},{"exchangeCode":"HAN"},{"exchangeCode":"HEL"},{"exchangeCode":"HKG"},{"exchangeCode":"ICE"},{"exchangeCode":"IOB"},{"exchangeCode":"ISE "},{"exchangeCode":"IST"},{"exchangeCode":"JKT"},{"exchangeCode":"JNB"},{"exchangeCode":"JPX"},{"exchangeCode":"KLS"},{"exchangeCode":"KOE"},{"exchangeCode":"KSC"},{"exchangeCode":"LIS"},{"exchangeCode":"LIT"},{"exchangeCode":"LSE"}, {"exchangeCode":"MCE"},{"exchangeCode":"MCX"},{"exchangeCode":"MEX"},{"exchangeCode":"MIL"},{"exchangeCode":"MUN"},{"exchangeCode":"NAE"},{"exchangeCode":"NCM"},{"exchangeCode":"NEO"},{"exchangeCode":"NGM"},{"exchangeCode":"NMS"},{"e xchangeCode":"NSI"},{"exchangeCode":"NYQ"},{"exchangeCode":"NZE"},{"exchangeCode":"OSL"},{"exchangeCode":"PAR"},{"exchangeCode":"PCX"},{"exchangeCode":"PNK"},{"exchangeCode":"PRA"},{"exchangeCode":"RIS"},{"exchangeCode":"SAO"},{"exch angeCode":"SAP"},{"exchangeCode":"SAU"},{"exchangeCode":"SES"},{"exchangeCode":"SET"},{"exchangeCode":"SGO"},{"exchangeCode":"SHH"},{"exchangeCode":"SHZ"},{"exchangeCode":"STO"},{"exchangeCode":"STU"},{"exchangeCode":"TAI"},{"exchangeCode":"TAL"},{"exchangeCode":"TLO"},{"exchangeCode":"TLV"},{"exchangeCode":"TOR"},{"exchangeCode":"TWO"},{"exchangeCode":"VAN"},{"exchangeCode":"VIE"}],"responseStatus":null}"
@tomatomov9061
@tomatomov9061 2 жыл бұрын
Have a question about the first unit test. Isn't this actually integrational test ? Because it interacts with the database ? We are not checking some isolated functionality but creating record and retrieving it.
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Yes..it combines different types of tests to get max coverage. A lot of the time, I'll use an in-memory db instead of mocking
@tomatomov9061
@tomatomov9061 2 жыл бұрын
@@GaryClarkeTech Thank you for thw answer!
@NoirExtra
@NoirExtra 3 жыл бұрын
Thank you very much for this awesome tutorial, even the speech flow is perfect ! It is good to see the concrete process of TDD. Do you think that it is possible to extend the process from the user story to the set of tests that should be created ? For exemple which user story could have led to the tests functions ? Again thanks a lot !
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
I'm working on a full testing course atm which will probably include that stuff. Keep an eye out for updates.
@puffkitty007
@puffkitty007 3 жыл бұрын
Thanks for this video Gary! I have a question. I get an error when i use setUp in StockTest.php: Method 'App\Tests\StockTest::setUp()' is not compatible with method 'Symfony\Bundle\FrameworkBundle\Test\KernelTestCase::setUp()' Do you know what causes this problem? Maybe it is because i use symfony 4? If so how can i fix this for symfony 4 because i need to use it for my usecase
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Hi Fardin..it shouldn't be related to Symfony 4 Can you paste both methods here and I'll look?
@puffkitty007
@puffkitty007 3 жыл бұрын
@@GaryClarkeTech I made a typo using Orm instead ORM in databaseprimer file. But now i have another problem because when i run the test it says: Caused by Doctrine\DBAL\Driver\PDO\Exception: could not find driver And: Caused by PDOException: could not find driver
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
@@puffkitty007 Try this: stackoverflow.com/questions/2852748/pdoexception-could-not-find-driver
@ElGovanni
@ElGovanni 2 жыл бұрын
49:03 why you just didn't use mock?
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
I can't really remember..it was recorded a while ago. But being able to demonstrate using the container for test replacements was part of the thinking.
@jordygroote2652
@jordygroote2652 3 жыл бұрын
Love this, thanks
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
You're welcome, Jordy
@bernardoalvarenga2607
@bernardoalvarenga2607 2 жыл бұрын
Great tutorial! Thanks. I am running into an issue though. Somehow it will not set that its running on the test environment. dd($kernel->getEnvironment()) on the DatabasePrimer will output 'dev' and then fail the check. Also it will not call the FakeYahooFinanceApiClient but the regular one. Seems that it is not at all obeying services_test.yaml. I did compare my code to your repo and all seems fine. I am using Symfony 5.4. Any ideas?
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Check your phpunit.xml file This is where APP_ENV gets set to test
@bernardoalvarenga2607
@bernardoalvarenga2607 2 жыл бұрын
@@GaryClarkeTech Thanks for replying. Yes, is there. Actually I downloaded your full code and updated to Symfony 5.4 ( 5.2 would not resolve) and the same issue there: $kernel->getEnvironment() is still returning 'dev'
@sergemaminiaina252
@sergemaminiaina252 3 жыл бұрын
Thank you
@AndrewErwin73
@AndrewErwin73 2 жыл бұрын
I am using a newer version of Symfony. All my tests are fine, but when I run the command, I get a "syntax error" reported from JsonDecode.php. However, there is no other information about what is causing this. I have not debugged yet (I have the hardest time getting xdebug to work with cli apps, but I will get there). Curious if anyone else has come across this error or has any ideas?
@mehdiphpbb
@mehdiphpbb 2 жыл бұрын
Excellent tutorial, but you have extracted the finance API to an interface which completely dependent on Yahoo API, the fetch method should not have any arguments bonded to a specific API, maybe the next API does not require the symbol and region.
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
Yes..there are a few things about it I would change tbh
@clementalquier1665
@clementalquier1665 3 жыл бұрын
Thanks a lot !
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
You're welcome!
@VazgenManukyan
@VazgenManukyan 2 жыл бұрын
Thank you. the only think that I do not understand is why you run `symfony composer` or `symfony PHP instead of just `composer` or `PHP`
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
I can't remember why I used it in this vid without watching it again. But symfony composer is used mainly for some shortcuts. If I need to have the symfony server for some things e.g. symfony server env vars then I'll prefix the command with symfony
@VazgenManukyan
@VazgenManukyan 2 жыл бұрын
@@GaryClarkeTech BTW i replied to your email yesterday, can you please check it?
@GaryClarkeTech
@GaryClarkeTech 2 жыл бұрын
@@VazgenManukyan Sorry but I haven't seen it / can't see it. It went to info@garyclarke.tech ?
@Shambhu384-l9h
@Shambhu384-l9h 3 жыл бұрын
awesome :)
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Thanks Shambhu..appreciated
@XivaGamer
@XivaGamer 3 жыл бұрын
i dont understand, i did everything ike you and i got this error when i tried to run test Doctrine\DBAL\Driver\PDO\Exception: SQLSTATE[HY000]: General error: 1 no such table: product
@XivaGamer
@XivaGamer 3 жыл бұрын
nvm i forgot about -> DatabasePrimer::prime($kernel);
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
That is indeed a strange error to receive because the only table I create in the whole tutorial is called stock. What have you named your entity?
@SteveMarvell
@SteveMarvell 3 жыл бұрын
Just the right length
@pawecyrklaf4729
@pawecyrklaf4729 3 жыл бұрын
Amazing :D If I could, I would have given it a 100 likes, but only one is possible: D
@GaryClarkeTech
@GaryClarkeTech 3 жыл бұрын
Thanks Pawel..I appreciate the one!
Symfony 5 HttpClient and TDD Tutorial (Part 1)
13:38
Gary Clarke
Рет қаралды 7 М.
Test Driven Development with Pest PHP
1:16:30
Gary Clarke
Рет қаралды 8 М.
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН
Counter-Strike 2 - Новый кс. Cтарый я
13:10
Marmok
Рет қаралды 2,8 МЛН
Who is More Stupid? #tiktok #sigmagirl #funny
0:27
CRAZY GREAPA
Рет қаралды 10 МЛН
Symfony 4 | Creating a Microservice (Part 1)
25:41
Qbrain
Рет қаралды 21 М.
Test Driven Development (TDD) in Spring
51:09
Dan Vega
Рет қаралды 29 М.
Create a Microservice with Symfony 6 (Full 5 Hour Course)
4:39:56
Gary Clarke
Рет қаралды 49 М.
C# Unit Testing - Full Course - Write Unit Tests in C# like a pro!
1:22:12
tutorialsEU - C#
Рет қаралды 50 М.
Learn Symfony in 1 Hour
1:11:01
Dave Hollingworth
Рет қаралды 6 М.
Spring Boot Testcontainers - Integration Testing made easy!
33:31
진짜✅ 아님 가짜❌???
0:21
승비니 Seungbini
Рет қаралды 10 МЛН