function UpdateMailTest::providerTestUpdateEmail

Provides data for ::testUpdateEmail.

Return value

array

  • The value of the update setting 'notification.threshold'.
  • An array of parameters for update_mail.
  • An array of expected message body strings.

File

core/modules/update/tests/src/Unit/UpdateMailTest.php, line 160

Class

UpdateMailTest
Tests text of update email.

Namespace

Drupal\Tests\update\Unit

Code

public static function providerTestUpdateEmail() : array {
  return [
    // Configured to notify for all available releases. Drupal Core is missing
    // an available update, there are no contrib modules installed.
'all: only core, not current' => [
      'all',
      [
        'core' => UpdateManagerInterface::NOT_CURRENT,
      ],
      [
        'There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to notify for all available releases. Drupal Core is missing
    // a security release, there are no contrib modules installed.
'all: only core, not secure' => [
      'all',
      [
        'core' => UpdateManagerInterface::NOT_SECURE,
      ],
      [
        'There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to notify for all available releases. Drupal Core is missing
    // an available update, contrib is up to date.
'all: core not current, contrib current' => [
      'all',
      [
        'core' => UpdateManagerInterface::NOT_CURRENT,
        'contrib' => UpdateManagerInterface::CURRENT,
      ],
      [
        'There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.',
        '',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to notify for all available releases. Drupal Core is up to
    // date, but contrib is missing an available update.
'all: core current, contrib not current' => [
      'all',
      [
        'core' => UpdateManagerInterface::CURRENT,
        'contrib' => UpdateManagerInterface::NOT_CURRENT,
      ],
      [
        '',
        'There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to notify for all available releases. Both Drupal Core and
    // contrib are missing available updates.
'all: both not current' => [
      'all',
      [
        'core' => UpdateManagerInterface::NOT_CURRENT,
        'contrib' => UpdateManagerInterface::NOT_CURRENT,
      ],
      [
        'There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.',
        'There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to notify for all available releases. Core is missing a
    // security release, contrib is up to date.
'all: core not secure, contrib current' => [
      'all',
      [
        'core' => UpdateManagerInterface::NOT_SECURE,
        'contrib' => UpdateManagerInterface::CURRENT,
      ],
      [
        'There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!',
        '',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to notify for all available releases. Core is missing a
    // security release, contrib is missing a regular update.
'all: core not secure, contrib not current' => [
      'all',
      [
        'core' => UpdateManagerInterface::NOT_SECURE,
        'contrib' => UpdateManagerInterface::NOT_CURRENT,
      ],
      [
        'There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!',
        'There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to notify for all available releases. Core is up to date,
    // but contrib is missing a security update.
'all: core current, contrib not secure' => [
      'all',
      [
        'core' => UpdateManagerInterface::CURRENT,
        'contrib' => UpdateManagerInterface::NOT_SECURE,
      ],
      [
        '',
        'There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to notify for all available releases. Core is missing a
    // regular update, contrib is missing a security update.
'all: core not current, contrib not secure' => [
      'all',
      [
        'core' => UpdateManagerInterface::NOT_CURRENT,
        'contrib' => UpdateManagerInterface::NOT_SECURE,
      ],
      [
        'There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.',
        'There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to notify for all available releases. Both core and contrib
    // are missing a security update.
'all: both not secure' => [
      'all',
      [
        'core' => UpdateManagerInterface::NOT_SECURE,
        'contrib' => UpdateManagerInterface::NOT_SECURE,
      ],
      [
        'There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!',
        'There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails when any updates are available. To get notified only for security updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to only show security notifications. Core is missing a
    // security release, no contrib modules installed.
'security: only core, not secure' => [
      'security',
      [
        'core' => UpdateManagerInterface::NOT_SECURE,
      ],
      [
        'There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to only show security notifications. Core is missing a
    // security release, contrib is up to date.
'security: core not secure, contrib current' => [
      'security',
      [
        'core' => UpdateManagerInterface::NOT_SECURE,
        'contrib' => UpdateManagerInterface::CURRENT,
      ],
      [
        'There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!',
        '',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to only show security notifications. Core is missing a
    // security release, contrib is missing a regular release.
'security: core not secure, contrib not current' => [
      'security',
      [
        'core' => UpdateManagerInterface::NOT_SECURE,
        'contrib' => UpdateManagerInterface::NOT_CURRENT,
      ],
      [
        'There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!',
        'There are updates available for one or more of your modules or themes. To ensure the proper functioning of your site, you should update as soon as possible.',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to only show security notifications. Core is up to date, but
    // contrib is missing a security update.
'security: core current, contrib not secure' => [
      'security',
      [
        'core' => UpdateManagerInterface::CURRENT,
        'contrib' => UpdateManagerInterface::NOT_SECURE,
      ],
      [
        '',
        'There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to only show security notifications. Core is missing a
    // regular update, contrib is missing a security update.
'security: core not current, contrib not secure' => [
      'security',
      [
        'core' => UpdateManagerInterface::NOT_CURRENT,
        'contrib' => UpdateManagerInterface::NOT_SECURE,
      ],
      [
        'There are updates available for your version of Drupal. To ensure the proper functioning of your site, you should update as soon as possible.',
        'There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
    // Configured to only show security notifications. Both core and contrib
    // are missing a security update.
'security: both not secure' => [
      'security',
      [
        'core' => UpdateManagerInterface::NOT_SECURE,
        'contrib' => UpdateManagerInterface::NOT_SECURE,
      ],
      [
        'There is a security update available for your version of Drupal. To ensure the security of your server, you should update immediately!',
        'There are security updates available for one or more of your modules or themes. To ensure the security of your server, you should update immediately!',
        "See the available updates page for more information:\nhttps://example.com/admin/reports/updates",
        'Your site is currently configured to send these emails only when security updates are available. To get notified for any available updates, https://example.com/admin/reports/updates/settings.',
      ],
    ],
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.