Let’s refactor our test and use the andAlsoExpectIt() method. You’ll also learn about Mockery’s ordered() method for declare the expectations should run in a specific order.
There are multiple behavior (task) options you can use for the expect() patching function: andReturn(), andReturnValues(), andReturnNull(), andReturnUsing(), and andThrow(). Let’s walk through each one and write some code to see how to use them in your testing suite.
Let’s talk about the anatomy of a test expectation in Brain Monkey. In this episode, you’ll discover how to structure an expectation as we look at when() and expect().
Let’s dive into the all of the different functions (toolset) that are available for you in Brain Monkey. We’ll look at the documentation and its test suite.
Before we can start adding Brain Monkey functionality to our tests, we need a test class. Let’s create that together in this episode. Here are the pro tips that I share in this episode: Load all of the needed source files in the setUp() method after the parent::setUp(). Why? Before we can redefine a function, Patchwork needs to load first and then the original source code. Load only the source files from the package (plugin or theme) that you are testing. Do not load WordPress core or other third party files. Why? You only load the original source code when […]
In this episode, you and I will walk through the Test Case and add in the setUp and tearDown for Brain Monkey, which then handles Patchwork and Mockery for us.
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[…]
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.
Notes | Transcript | Code | Playlist Notes Next, we need to define the constants we’ll need as the baseline for directory locations. Transcript Code