Book Image

Drupal 10 Module Development - Fourth Edition

By : Daniel Sipos
Book Image

Drupal 10 Module Development - Fourth Edition

By: Daniel Sipos

Overview of this book

Embark on a journey of Drupal module development with the latest edition of this must-have guide written by Daniel Sipos – a Drupal community member! This fourth edition is meticulously revised to cover the latest Drupal 10 enhancements that will help you build custom Drupal modules with an understanding of code deprecations, changing architecture, data modeling, multilingual ecosystem, and so on. You’ll begin with understanding the core components of Drupal 10 architecture, discovering its subsystems and unlocking the secrets of creating your first Drupal module. Further, you'll delve into Drupal logging and mailing systems, creating theme hooks, and rendering a layout. As you progress, you'll work with different types of data storage, custom entities, field types, and work with Database APIs for lower-level database queries. You'll learn to reap the power of JavaScript and ensure that your code works seamlessly on multilingual sites. You'll also learn to create custom views, automate tests for your functionalities, and write secure code for your Drupal apps. By the end of this book, you'll have gained confidence in developing complex modules that can solve even the most complex business problems and might even become a valuable contributor to the Drupal community!
Table of Contents (21 chapters)
3
Chapter 3: Logging and Mailing

Kernel tests

Kernel tests are the immediate higher-level testing methodology we can have in Drupal and are actually integration tests that focus on testing various components. They are faster than regular Functional tests as they don’t do a full Drupal install, but use an in-memory pseudo installation that is much faster to bootstrap. For this reason, they also don’t handle any browser interactions and don’t install any modules automatically.

Apart from the code itself, Kernel tests also work with the database and allow us to load the modules that we need for running the test. However, unlike the Functional tests we will see next, Kernel tests also require us to manually trigger the installation of any database schemas we need. But we will see how we can do this in the two examples we cover in this section.

Before we can work with Kernel tests, though, we need to make sure we have a connection to the database, and that PHPUnit is aware of this. Inside the...