Explore using the patterns developed in TDD to build code that is decoupled or code that doesn't depend so heavily on what exactly is done by other classes in your codebase.
- [Teacher] The goal with decoupling code is to pull…out dependencies and requirements from our software,…to permit our dependencies to be easily swappable.…This ability to swap our dependencies…also makes them easier to test.…Let's try this out.…If we look at our Receipt class in our…source directory, we'll pull out our method…for currencyAmt into a new class Formatter.…This Formatter class, we can use to…fill up with various formatting methods.…This should be a pretty easy method to extract out,…and more importantly, it'll allow us to keep…the formatting details of currencyAmt separate…from the map for calculating the receipt.…
To begin, we need to first add a test class…for this new class in a corresponding test method.…First, we'll create a new file in our…test directory called FormatterTest.…And now we need to add the basics for our file.…First, our open php tags,…and then our namespace on line 2 as namespace TDD\Test,…and on line 3, our require line that we can…copy and paste from our receiptTest.php class.…
- Why use unit testing?
- Writing unit tests
- Extending unit tests
- Filtering PHPUnit tests
- Building dummy objects
- Working with data providers
- Writing an exception-based test
- Using TDD tactics
- Using PHPUnit advanced tactics, such as database tests
Skill Level Intermediate
Managing PHP Persistent Sessionswith David Powers2h 41m Intermediate
1. The Basics of Test-Driven Development
2. Advanced Test-Driven Development
3. Test-Driven Development Tactics
4. PHPUnit Advanced Tactics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.