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.
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.
Run and Review the Starter Test Suite
Lab Introduction
Centralized Data, State, & Config Store – Built in OOP
Let’s build the centralized data, state, and configuration parameters store in an Object Oriented (OOP) architecture. What You Will Learn X Prerequisites See the list of prerequisites and suggestions on the series landing page.
Data Store – Build, Test, & Validate the Advanced Features
This is part 4 of the series. In this hands-on coding lab, you’ll build, test, and validate more advanced features for the data store, thereby extending its functionality and utility.
Data Store – Planning the Requirements
Before we can build the data store, we need to understand what it is we need to build. In this lab, you’ll think through each of the requirements, working to define what makes a store a store, how to interact with it, what functionality is needed, and conceptually how to achieve it, and then what approaches you’ll employ in the series.
Unit Testing with Brain Monkey
How can you unit test your plugin or theme without WordPress or other dependencies? You simulate the dependencies. My favorite tool to redefine and mock functions is Brain Monkey. In this hands-on testing lab, you will write unit tests using Brain Monkey.
`with()` – Code Challenge
Let’s walk through the code challenge I gave to you in the last episode.
More with `with()`
Let’s build another test to learn more about using with()
`with()`
We can test that the arguments the mocked function receives are what we expect by using the with() method. Mockery, which is baked into Brain Monkey, inspects the received arguments and then tests each one against what you’ve defined it should receive. This feature allows us to ensure our code is properly doing its work and sending the right set of data to the function we are mocking. Here, let me show you.