In this lesson, we will not write code but look at a typical "plan" behind every test method.
One of the most common ways to write tests is to divide any function into three phases, and they all start with an "A" letter. It's a "AAA". You can call it a 3-step framework:
- Arrange
- Act
- Assert
In most cases, you should stick to this plan for every function in your test.
Step 1. Arrange.
You can call it a "preparation" step.
Add any data you need, any configuration. Build the scenario.
test('homepage contains non empty table', function () { Product::create([ 'name' => 'Product 1', 'price' => 123, ]); get('/products') ->assertStatus(200) ->assertDontSee(__('No products found'));});
Step 2. Act.
This step is usually about...