update_get_available example

'administer software updates',
      'administer site configuration',
    ]);
    $this->drupalLogin($admin_user);
  }

  /** * Tests upload, extraction, and update of a module. */
  public function testUploadModule() {
    // Ensure that the update information is correct before testing.     update_get_available(TRUE);

    // Images are not valid archives, so get one and try to install it. We     // need an extra variable to store the result of drupalGetTestFiles()     // since reset() takes an argument by reference and passing in a constant     // emits a notice in strict mode.     $imageTestFiles = $this->drupalGetTestFiles('image');
    $invalidArchiveFile = reset($imageTestFiles);
    $edit = [
      'files[project_upload]' => $invalidArchiveFile->uri,
    ];
    // This also checks that the correct archive extensions are allowed.
/** * Returns a page about the update status of projects. * * @return array * A build array with the update status of projects. */
  public function updateStatus() {
    $build = [
      '#theme' => 'update_report',
    ];
    if ($available = update_get_available(TRUE)) {
      $this->moduleHandler()->loadInclude('update', 'compare.inc');
      $build['#data'] = update_calculate_project_data($available);

      // @todo Consider using 'fetch_failures' from the 'update' collection       // in the key_value_expire service for this?       $fetch_failed = FALSE;
      foreach ($build['#data'] as $project) {
        if ($project['status'] === UpdateFetcherInterface::NOT_FETCHED) {
          $fetch_failed = TRUE;
          break;
        }
      }
$this->moduleHandler->loadInclude('update', 'inc', 'update.manager');

    $form['last_check'] = [
      '#theme' => 'update_last_check',
      '#last' => $this->state->get('update.last_check', 0),
    ];

    if (!_update_manager_check_backends($form, 'update')) {
      return $form;
    }

    $available = update_get_available(TRUE);
    if (empty($available)) {
      $form['message'] = [
        '#markup' => $this->t('There was a problem getting update information. Try again later.'),
      ];
      return $form;
    }

    $form['#attached']['library'][] = 'update/drupal.update.admin';

    // This will be a nested array. The first key is the kind of project, which     // can be either 'enabled', 'disabled', 'manual' (projects which require
    // 'No available releases found' string.     $this->assertSession()->responseContains('<h3>Drupal core</h3>');
    $this->assertSession()->linkExists('Drupal');
    $this->assertSession()->linkByHrefExists('http://example.com/project/drupal');
    $this->assertSession()->pageTextContains('Up to date');
    $this->assertSession()->responseContains('<h3>Modules</h3>');
    $this->assertSession()->pageTextNotContains('Update available');
    $this->assertSession()->pageTextContains('No available releases found');
    $this->assertSession()->linkNotExists('AAA Update test');
    $this->assertSession()->linkByHrefNotExists('http://example.com/project/aaa_update_test');

    $available = update_get_available();
    $this->assertFalse(isset($available['aaa_update_test']['fetch_status']), 'Results are cached even if no releases are available.');
  }

  /** * Tests the basic functionality of a contrib module on the status report. */
  public function testUpdateContribBasic() {
    $system_info = [
      '#all' => [
        'version' => '8.0.0',
      ],
      
Home | Imprint | This part of the site doesn't use cookies.