• Development

    Writing Tests for Drush Commands

    There are plenty of examples of these in the wild, but I figured I’d show a stripped down version of an automated Kernel test that successfully tests a drush command. The trick here is making sure you set up a logger and that you stub a few methods (if you happen to use $this->logger()  and dt()  in your Drush commands). Also featured in this example is the use of Faker to generate realistic test data.

    I learned this via the migrate_tools project here.

  • Development

    Skip Empty Values During Concatenation in a Drupal 10 Migration

    UPDATE. You can do the same as below without the need for a custom module function. (source)


    This quick example shows one method to ignore empty values in a Drupal 10 migration concatenate process.

    Code

    Migrate code:

    Module code:

    Result

    Example data:

    Resulting field_address_full plain text value