Your local web development environment is critical to your ability to efficiently produce high quality and well-tested software projects. This environment should be incredibly easy to use. It should support the way you work, making you better and faster while demanding very little of your time. In this hands-on lab, you will setup your local web development environment. It will include version control with Git, helper apps, package managers (Composer, Node, and npm), task runner with Gulp, local webserver, and a professional editor.
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.
Behind the Scenes of Redefining a Function
In the last episode, we talked about the philosophy of unit testing, i.e. testing in isolation without the function’s dependencies. In order to test in isolation, we need to know what each dependent function will do within the context of that test (i.e. given conditions) and then write a function that redefines the original in order to force it to do what it should. In this episode, you and I will dive into what is happening between the scenes in the PHP internals of user-defined names and memory). I’ll give you an overview to help you visualize how Brain Monkey[…]
The Problem – Why We Need to Simulate
Let’s explore both the philosophy of unit testing (i.e. testing in isolation) and the problem we face of redefining dependent functions in order to achieve a pure unit test.
Integration Bootstrap – Defining Constants
Notes | Transcript | Code | Playlist Notes Next, we need to define the constants we’ll need as the baseline for directory locations. Transcript Code
Integration Bootstrap – Register Theme & Load
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
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
Integration Bootstrap – Find the WordPress Test Suite’s Directory
Notes | Transcript | Code | Playlist Notes Next, we need to find where the WordPress test suite’s directory is on your localhost’s web server. Transcript Code