documentation in CronInterface is out of date and incomplete

Created on 8 February 2023, about 2 years ago

Problem/Motivation

Docs in CronInterface say:

   * Do not call this function from a test. Use $this->cronRun() instead.

First, this is incomplete -- what is $this representing here? There is no cronRun() method on the interface.

It what is meant is \Drupal\Tests\Traits\Core\CronRunTrait -- that's the only place in core I can find a function with this name. The full name should be given in the docs.

Second, this is partially incorrect, or possibly predates the existence of Kernel tests, because the code of cronRun() is this:

    $this->drupalGet('cron/' . \Drupal::state()->get('system.cron_key'));

Unit and Kernel tests can't do browser requests with drupalGet().

So the docs are misleading, and should say that the function should be used in *browser* tests.

Third, I'm not clear why cron should be run by making a browser request, rather than through the API. That should be explained too.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

10.1 โœจ

Component
Documentationย  โ†’

Last updated 4 days ago

No maintainer
Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024