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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

Status: Active » Needs review
FileSize
3.03 KB

Here'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)

Status: Needs review » Needs work

The last submitted patch, 2: 3079133-1.drush-phpunit-test.patch, failed testing. View results

jonathan1055’s picture

Status: Needs work » Needs review
FileSize
4.19 KB

As expected the new Drush test failed with

Error: Call to a member function runLightweightCron() on null in Drupal\scheduler\Commands\SchedulerCommands->cron() (line 59 of /var/www/html/modules/contrib/scheduler/src/Commands/SchedulerCommands.php)

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()

jonathan1055’s picture

Typo in composer.json

jonathan1055’s picture

Now to see if it works with the composer change only and not the drupalci.yml commands to get drush.

jonathan1055’s picture

So 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.

jonathan1055’s picture

Added a second drush test, to check that the nodes are actually processed during the cron run.

  • jonathan1055 committed ce01db0 on 8.x-1.x
    Issue #3079133 by jonathan1055: Add Phpunit test to check Drush commands
    
jonathan1055’s picture

Status: Needs review » Fixed

Done.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.