Notes | Transcript | Code | Playlist Notes We’re almost done with the bootstrap file. Whew! Right? In this episode, you and I will finish it. We need to: Load the WordPress tests suite’s includes/bootstrap.php file. Register a callback to the tests “theme_setup” event. When that event fires, we want to define where our themes directory is and switch the default theme to our theme. Finally, let’s load WordPress’ testing suite. Transcript Code
Labs
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
Integration Bootstrap – Overview
Notes | Transcript | Code | Playlist Notes In this episode, we’ll start laying out the steps to bootstrap our integration tests. Transcript Code
Wrap it Up
WooHoo! You did it! You made it through this lab. In doing so, you setup your testing environment, learned a few new things about Composer, dove into the formula for figuring out what to test, and wrote real unit and integration tests. Congratulations for completing this lab!
Integration Tests – Write Real Tests
Notes | Transcript | Code | Playlist Notes Let’s write a real test together. Remember back in an earlier episode where I told you that I found a bug in beans_replace_action() and beans_replace_action_hook()? Let’s write the test for that bug. You’ll get using the added functionality from WordPress’ Test Case, as you’ll create a new post and use the go_to() method. Transcript Code
Meet WP_UnitTestCase
Notes | Transcript | Playlist Notes WordPress packages a bunch of functionality for us to use in our integration tests. You extend off of the WP_UnitTestCase to gain access to things like: Factory for creating post content (i.e. posts, pages, and custom post types), terms, users, etc.) Loading a URL via go_to() Query tests to check that you did load the right stuff Setup for the query, global states, etc. Resets to return us to that original setup state, query, etc. Let’s talk about it in this episode. Transcript
Setup Local’s Web Server
Notes | Transcript | Playlist Notes Are you running Local by Flywheel, like me? If no, you can skip this episode. But if yes, then in this episode, you and I will install the packages we need as well as get WordPress setup. It’s really easy as Kees Meijer already has the bash script and instructions ready for you. Click here to get the script. Transcript
Setup Test Shortcuts in Composer
Notes | Transcript | Code | Playlist Notes In this episode, you’ll be: Installing all of the dependencies specified by running composer install. Fixing a namespace error in the composer.json file. Adding in the integration tests PSR-4 configuration. Adding in the scripts, which will make your testing job so much easier. Transcript Code
Create the Composer.json File
Notes | Transcript | Code | Playlist Notes In this episode, you and I will create a composer.json file to configure all of the dependencies we will need for our testing suites. Transcript Code
Test Assertions
Notes | Transcript | Code | Playlist Notes A great way to learn which assertions to use for your tests is to take the equivalent comparative code and find the assertion that does the comparison work for you. In this episode, I’m going to challenge you to do just that. I want you to take our test sample assertions, which are all assertTrue(), look at the comparison code, and figure out which assertion can replace that code. You’ll be using the PHPUnit manual. Then together, you and I will walk through the process together. We’ll look at the different assertions […]
How Testing Benefits You
Notes | Transcript | Code | Playlist Notes Before we can really dive into testing, I think any conversation about integration testing into workflow has to start with “how it benefits you.” Testing requires more work from you upfront, but saves you time and money later. The benefits are huge to your company, clients, and you. Let’s talk about why and what you get. In this episode, I’ll show you the benefits of testing by showing you a real world framework that had a bug in it. As I was writing tests for it, I found a bug, one that […]