You are here

public function UpdateFetcherTest::providerTestUpdateBuildFetchUrl in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/update/tests/src/Unit/UpdateFetcherTest.php \Drupal\Tests\update\Unit\UpdateFetcherTest::providerTestUpdateBuildFetchUrl()

Provide test data for self::testUpdateBuildFetchUrl().

Return value

array An array of arrays, each containing:

  • 'project' - An array matching a project's .info file structure.
  • 'site_key' - An arbitrary site key.
  • 'expected' - The expected url from UpdateFetcher::buildFetchUrl().

File

core/modules/update/tests/src/Unit/UpdateFetcherTest.php, line 69
Contains \Drupal\Tests\update\Unit\UpdateFetcherTest.

Class

UpdateFetcherTest
Tests update functionality unrelated to the database.

Namespace

Drupal\Tests\update\Unit

Code

public function providerTestUpdateBuildFetchUrl() {
  $data = array();

  // First test that we didn't break the trivial case.
  $project['name'] = 'update_test';
  $project['project_type'] = '';
  $project['info']['version'] = '';
  $project['info']['project status url'] = 'http://www.example.com';
  $project['includes'] = array(
    'module1' => 'Module 1',
    'module2' => 'Module 2',
  );
  $site_key = '';
  $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
  $data[] = array(
    $project,
    $site_key,
    $expected,
  );

  // For disabled projects it shouldn't add the site key either.
  $site_key = 'site_key';
  $project['project_type'] = 'disabled';
  $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
  $data[] = array(
    $project,
    $site_key,
    $expected,
  );

  // For enabled projects, test adding the site key.
  $project['project_type'] = '';
  $expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
  $expected .= '?site_key=site_key';
  $expected .= '&list=' . rawurlencode('module1,module2');
  $data[] = array(
    $project,
    $site_key,
    $expected,
  );

  // Test when the URL contains a question mark.
  $project['info']['project status url'] = 'http://www.example.com/?project=';
  $expected = 'http://www.example.com/?project=/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
  $expected .= '&site_key=site_key';
  $expected .= '&list=' . rawurlencode('module1,module2');
  $data[] = array(
    $project,
    $site_key,
    $expected,
  );
  return $data;
}