function UpdateReportTest::testTemplatePreprocessUpdateFetchErrorMessageNoDblog

Same name in other branches
  1. 9 core/modules/update/tests/src/Kernel/UpdateReportTest.php \Drupal\Tests\update\Kernel\UpdateReportTest::testTemplatePreprocessUpdateFetchErrorMessageNoDblog()
  2. 11.x core/modules/update/tests/src/Kernel/UpdateReportTest.php \Drupal\Tests\update\Kernel\UpdateReportTest::testTemplatePreprocessUpdateFetchErrorMessageNoDblog()

Tests the error message when failing to fetch data without dblog installed.

See also

template_preprocess_update_fetch_error_message()

File

core/modules/update/tests/src/Kernel/UpdateReportTest.php, line 69

Class

UpdateReportTest
Tests update report functionality.

Namespace

Drupal\Tests\update\Kernel

Code

public function testTemplatePreprocessUpdateFetchErrorMessageNoDblog() : void {
    $build = [
        '#theme' => 'update_fetch_error_message',
    ];
    $this->render($build);
    $this->assertRaw('Failed to fetch available update data:<ul><li>See <a href="https://www.drupal.org/node/3170647">PHP OpenSSL requirements</a> in the Drupal.org handbook for possible reasons this could happen and what you can do to resolve them.</li><li>Check your local system logs for additional error messages.</li></ul>');
    \Drupal::moduleHandler()->loadInclude('update', 'inc', 'update.report');
    $variables = [];
    template_preprocess_update_fetch_error_message($variables);
    $this->assertArrayHasKey('error_message', $variables);
    $this->assertEquals('Failed to fetch available update data:', $variables['error_message']['message']['#markup']);
    $this->assertArrayHasKey('documentation_link', $variables['error_message']['items']['#items']);
    $this->assertArrayHasKey('logs', $variables['error_message']['items']['#items']);
    $this->assertArrayNotHasKey('dblog', $variables['error_message']['items']['#items']);
}

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