function UpdateTestTrait::mockInstalledExtensionsInfo

Same name in other branches
  1. 10 core/modules/update/tests/src/Functional/UpdateTestTrait.php \Drupal\Tests\update\Functional\UpdateTestTrait::mockInstalledExtensionsInfo()

Sets information about installed extensions.


  'drupal' => [
    'project' => 'drupal',
    'version' => '8.0.0',
    'hidden' => FALSE,
  ]

Parameters

string[][] $installed_extensions: An array containing mocked installed extensions info. Keys are extension names, values are arrays containing key-value pairs that would be present in extensions' *.info.yml files. For a list of accepted keys, see InfoParserInterface. Key-value pairs not present here will be inherited from $default_info. For example:

Throws

\Exception

18 calls to UpdateTestTrait::mockInstalledExtensionsInfo()
UpdateContribTest::doTestSecurityUpdateAvailability in core/modules/update/tests/src/Functional/UpdateContribTest.php
Tests update status of security releases.
UpdateContribTest::testCoreCompatibilityMessage in core/modules/update/tests/src/Functional/UpdateContribTest.php
Tests that core compatibility messages are displayed.
UpdateContribTest::testHookUpdateStatusAlter in core/modules/update/tests/src/Functional/UpdateContribTest.php
Checks that hook_update_status_alter() works to change a status.
UpdateContribTest::testNonStandardVersionStrings in core/modules/update/tests/src/Functional/UpdateContribTest.php
Tests messages for invalid, empty and missing version strings.
UpdateContribTest::testNoReleasesAvailable in core/modules/update/tests/src/Functional/UpdateContribTest.php
Tests when there is no available release data for a contrib module.

... See full list

File

core/modules/update/tests/src/Functional/UpdateTestTrait.php, line 39

Class

UpdateTestTrait
Provides a trait to set system info and XML mappings.

Namespace

Drupal\Tests\update\Functional

Code

protected function mockInstalledExtensionsInfo(array $installed_extensions) : void {
    if (in_array('#all', array_keys($installed_extensions), TRUE)) {
        throw new \Exception("#all (default value) shouldn't be set here instead use ::mockDefaultExtensionsInfo().");
    }
    $system_info = $this->config('update_test.settings')
        ->get('system_info');
    $system_info = $installed_extensions + $system_info;
    $this->config('update_test.settings')
        ->set('system_info', $system_info)
        ->save();
}

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