Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
My error in #2951072: Provide Scheduler drush commands for Drush 9 which is fixed in #3078674: Call to function runLightweightCron() on null in SchedulerCommands->cron() shows the benefit of having a phpunit test to cover the drush command. This is not a very common thing for contrib modules to do, and I only found one example so far, in the Devel project. But it seems quite straighforward and definitely worth doing.
Comment | File | Size | Author |
---|---|---|---|
#8 | 3079133-8.drush-phpunit-test.patch | 4.26 KB | jonathan1055 |
|
Comments
Comment #2
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHere's a patch which adds a new test file for drush. Also drush needs to be installed via a command in drupalci.yml. Also for good measure I added it into composer.json test requirements.
The new test should fail, because the fix for #3078674: Call to function runLightweightCron() on null in SchedulerCommands->cron() has not been committed yet (purposely to try this new phpunit test on drupal.org)
Comment #4
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedAs expected the new Drush test failed with
We also got the Rules test failures which are caused by patching composer.json - see #2985051: Patching composer.json shows we need to add module dependencies
Here's a patch with the cron drush fix from #3078674: Call to function runLightweightCron() on null in SchedulerCommands->cron()
Comment #5
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedTypo in composer.json
Comment #6
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedNow to see if it works with the composer change only and not the drupalci.yml commands to get drush.
Comment #7
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedSo it works fine without the container command mentioned in https://git.drupalcode.org/project/devel/blob/HEAD/drupalci.yml
Seems like having require-dev drush is in the composer.json file is sufficient.
Comment #8
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedAdded a second drush test, to check that the nodes are actually processed during the cron run.
Comment #10
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedDone.