function ProjectInfoTest::testGetInstallableReleases

@covers ::getInstallableReleases

@dataProvider providerGetInstallableReleases

Parameters

string $fixture: The fixture file name.

string $installed_version: The installed version core version to set.

string[] $expected_versions: The expected versions.

File

core/modules/package_manager/tests/src/Kernel/ProjectInfoTest.php, line 29

Class

ProjectInfoTest
@coversDefaultClass \Drupal\package_manager\ProjectInfo[[api-linebreak]] @group auto_updates @internal

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testGetInstallableReleases(string $fixture, string $installed_version, array $expected_versions) : void {
  [
    $project,
  ] = explode('.', $fixture);
  $fixtures_directory = __DIR__ . '/../../fixtures/release-history/';
  if ($project === 'drupal') {
    $this->setCoreVersion($installed_version);
  }
  else {
    // Update the version and the project of the project.
    $this->enableModules([
      'package_manager_test_update',
    ]);
    $extension_info_update = [
      'version' => $installed_version,
      'project' => 'package_manager_test_update',
    ];
    // @todo Replace with use of the trait from the Update Status module in https://drupal.org/i/3348234.
    $this->config('update_test.settings')
      ->set("system_info.{$project}", $extension_info_update)
      ->save();
    // The Update Status module will always request Drupal core's update XML.
    $metadata_fixtures['drupal'] = $fixtures_directory . 'drupal.9.8.2.xml';
  }
  $metadata_fixtures[$project] = "{$fixtures_directory}{$fixture}";
  $this->setReleaseMetadata($metadata_fixtures);
  $project_info = new ProjectInfo($project);
  $actual_releases = $project_info->getInstallableReleases();
  // Assert that we returned the correct releases in the expected order.
  $this->assertSame($expected_versions, array_keys($actual_releases));
  // Assert that we version keys match the actual releases.
  foreach ($actual_releases as $version => $release) {
    $this->assertSame($version, $release->getVersion());
  }
}

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