Testing is a critical component of your workflow, as it validates each piece of your code to ensure it works exactly as you intended. As a professional developer, testing is a skill that will set you a part and give you a competitive advantage in the marketplace. In this hands-on lab, you will be building unit and integration tests as you learn the basics of PHP testing.
What You Will Learn
In this hands-on lab, you will gently ease into testing. You’ll learn about:
- What testing is.
- Its many benefits that make you and your products/projects better.
- How to set up your testing environment.
- Basic testing elements including:
- What an “assertion” is and what it’s doing.
- The Test Case
- Test bootstrap
- Configuring the tests in the XML file.
- How to write a test that validates a single piece of your code.
- Different PHPUnit assertions available to you.
- The difference between unit and integration tests.
- Workflow shortcut – using Composer scripts to make running tests easier.
- and more
In order to do this lab, you will need:
- a local sandbox site spun up and ready to go (we’ll use this for the Integration Tests)
- Composer installed – for Mac or Windows
- a command line tool – I’m using PhpStorm for unit tests and iTerm2 for integration tests.
- your favorite code editor or IDE – I’m using PhpStorm.
Hey... hey you... yes you!... Having a good time? Learning new things? Good!
Total Lab Runtime: 04:26:49
- 1 Lab Introductionfree 13:13
- 2 How Testing Benefits Youfree 27:00
- 3 What is Testing?free 10:24
- 4 Unit vs. Integration Testsfree 17:44
- 5 Setup the Testing Environmentpro 12:21
- 6 PHPUnit & a Virtual Containerpro 08:37
- 7 Create the Composer.json Filepro 14:36
- 8 Configure PHPUnit for Both Test Suitespro 10:56
- 9 Setup Test Shortcuts in Composerpro 09:58
- 10 Setup Local's Web Serverfree 10:05
- 11 Unit Tests - Bootstrappro 14:34
- 12 Test Basicspro 12:24
- 13 Test Assertionspro 18:42
- 14 Unit Tests - Write Real Testspro 23:32
- 15 Integration Bootstrap - Overviewfree 09:01
- 16 Integration Bootstrap - Find the WordPress Test Suite's Directorypro 12:10
- 17 Integration Bootstrap - Defining Constantspro 04:06
- 18 Integration Bootstrap - Register Theme & Loadpro 07:41
- 19 Meet WP_UnitTestCasepro 12:05
- 20 Integration Tests - Write Real Testspro 15:18
- 21 Wrap it Upfree 02:22
Check out the PHP Library for more hands-on labs, insights, Docx, and more.