Let’s run the starter test suite to ensure everything is setup and ready to go. Then we’ll walk through the test suite basics.
Notes | Transcript | Code | Playlist Notes Next, we need to define the constants we’ll need as the baseline for directory locations. Transcript Code
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
Notes | Transcript | Code | Playlist Notes In this episode, we’ll start laying out the steps to bootstrap our integration tests. Transcript Code
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!
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
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
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
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
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