• 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

    When Did Drupal Cron Last Run?

    Here’s a simple drush command to determine when Drupal cron (and node index cron) last ran: