In the previous two lessons, you've created a Drupal project with PHPUnit and have a running test suite that uses users and content created as part of each test.
With what you've learned, let's create a simple Blog module with tests and test-driven development.
## Creating the Blog page
First, let's create a page that will list the posts. This will be similar to our first tests for Drupal's front and admin pages.
Create a new `BlogPageTest` and have it extend `BrowserTestBase`.
Let's assert that a page should exist at `/blog` by returning a `200` status code, as this should be accessible by anonymous users.
As you haven't created it, the status code should be a `404` - causing the test to fail.
> Tip: you can use `--filter testBlogPage` to run a single test or `--stop-on-failure` to stop running the tests as soon as an error occurs. These should shorten the time to run your tests, as you only run the tests you need.
Whilst you could create the page using the Views module, let's create a custom route.
Note the namespace is different from the one within the test classes and we don't need to extend any other classes.
For this step, the simplest thing you can do to get a passing test is to return an empty render array.
As long as it's an array, even an empty one, the test should pass:
```php
public function __invoke(): array {
return [];
}
```
As a rule, you want the tests to pass as often and quickly as possible by doing the simplest thing to achieve it - even returning a hard-coded value or an empty array.
Now the test passes, you can add to it and drive out the next piece of functionality.
As the node titles are within the page content, the test should pass.
To be confident, try returning an empty array again or removing the foreach loop, seeing the test fail, and reverting the change.
Confidence comes from tests that pass and fail when expected, so you're sure the correct behaviour is being tested, and the tests aren't passing accidentally.
You can add further tests, such as checking that only nodes of a specified node type are returned. Currently, all nodes would be listed, even if they aren't posts.
## Asserting posts are in the correct order
We have a list of post titles on a page and a test to prove it, but what if we want to ensure the posts are shown in a specified order?
That's harder to do with a functional test, so in the next lesson, we'll refactor the code and look at Kernel tests.