Drupal's migration system allows the use of a number of different plugins to perform source, processing, and destination functions.
Process plugins are responsible for copying and sometimes manipulating data into the destination. There are a number of different process plugins that allow you to get data in different ways and and apply it to your destination fields.
Both the core Migrate module and the excellent Migrate Plus module contain a number of different process plugins that you can use to process your data in different ways.
Out of the box, the default process plugin is the get plugin, which can be used like this in your migration scripts.
destination_field:
plugin: get
source: source_field
This is often shortened to the following, which has exactly the same functionality.
destination_field: source_field
Most of the time you will want to avoid creating custom plugins, but sometimes your migration requirements will necessitate their use. You might find that your source data is very messy and needs to be cleaned up before importing it into the site. Process plugins are a really good way of doing this, but it is essential that you write tests to cover every situation that you might encounter.
In this article we will look at two custom migrate process plugins that are built in different ways and how to test them. This will dive into some concepts around Drupal plugin management, dependency injection, as well as unit testing and data providers with PHPUnit.
First, let's look at the migration script that we will be using in this article. All of the source code for this migration example is available on GitHub.