mglaman / drupal-change-record-triage

Used to triage Drupal change records to ensure phpstan-drupal, drupal-rector, and upgrade_status have appropriate issues.
MIT License
6 stars 0 forks source link

A new test trait allows configuring update_test module settings #594

Open github-actions[bot] opened 1 year ago

github-actions[bot] commented 1 year ago

https://www.drupal.org/node/3358840

Introduced in branch/version: 10.2.x / 10.2.0

  1. New UpdateTestTrait has three methods to update config keys system_info and xml_map in update_test.settings
  2. Removed the pattern $this->config('update_test.settings')->set('the key') for system_info and xml_map, replaced with 3 aptly named methods mockInstalledExtensionsInfo , mockDefaultExtensionsInfo and mockReleaseHistory
  3. Added relevant info + references and examples for the methods.

Example

Set system_info

before

$system_info = 
     [
      '#all' => [
        'version' => '8.0.0',
      ],
     'aaa_update_test' => [
        'project' => 'aaa_update_test',
        'version' => '8.x-1.0',
        'hidden' => FALSE,
      ],
    ]

$this->config('update_test.settings')->set('system_info', $system_info)->save();

after

$installed_extensions = 
    [
     'aaa_update_test' => [
        'project' => 'aaa_update_test',
        'version' => '8.x-1.0',
        'hidden' => FALSE,
      ],
    ]

$this->mockInstalledExtensionsInfo($installed_extensions);
$this->mockDefaultExtensionsInfo(['version' => '8.0.0']);

Set xml_map

before

    $this->config('update_test.settings')
      ->set('xml_map', ['drupal' => 'sec.0.2'])
      ->save();

after

$this->mockReleaseHistory(['drupal' => 'sec.0.2']);

bbrala commented 1 year ago

Although not sure if this could be detected in phpstan.