Instead of returning a result, this also results in an error:
> Error: Call to a member function loadByProperties() on null
Within `PostNodeRepository`, we use the `getStorage()` on `EntityTypeManager` to get the node storage, which is an instance of `EntityStorageInterface`.
For the test to work, this needs to be mocked too and returned from the `getStorage()` method.
Create a mock of `EntityStorageInterface`, which will be used as the node storage:
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.
Blog Page (Drupal\Tests\atdc\Functional\BlogPage)
✔ Blog page
✔ Posts are visible
✔ Only published nodes are shown
✔ Only post nodes are shown
Post Builder (Drupal\Tests\atdc\Kernel\Builder\PostBuilder)
✔ It returns a published post
✔ It returns an unpublished post
✔ It returns a post with tags
Post Node Repository (Drupal\Tests\atdc\Kernel\PostNodeRepository)
✔ Posts are returned by created date
Post Node Repository Unit (Drupal\Tests\atdc\Unit\PostNodeRepositoryUnit)
✔ It returns posts
Time: 00:07.097, Memory: 10.00 MB
OK (9 tests, 71 assertions)
```
Everything should be passing, and your testsuite should have a combination of different types of tests.
In this course, you've learned:
- How to configure Drupal and PHPUnit to run automated tests.
- How to write functional, kernel and unit tests.
- How to create data, such as node types, content and users within tests.
- How to manage configuration using test-specific modules.
- How to write unit tests and use mocks.
- Some small PHP tips and tricks, such as promoted constructor properties and the `@test` and `@testdox` parameters in PHPUnit.
I couldn't cover everything in a short email course, but I hope it was useful.
## Questions and feedback
Thank you for taking my Introduction to Automated Testing in Drupal email course.
I'd appreciate any feedback, so if you wouldn't mind, press reply and let me know what you thought of the course.
Also, I'd love to know your next steps are and what I can do to help.
You can register for my [Daily Email list][daily] to get daily software development emails and updates about future products and courses or see when the next date is for my [online Drupal testing workshop][dto].
I also offer private workshops and talks for development teams, [1-on-1 consulting calls][call] and [pair programming sessions][pair], [development team coaching][team] and [Drupal development subscriptions][subscription].