You are here

public function UpdateContribTest::testUpdateContribBasic in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/update/tests/src/Functional/UpdateContribTest.php \Drupal\Tests\update\Functional\UpdateContribTest::testUpdateContribBasic()

Tests the basic functionality of a contrib module on the status report.

File

core/modules/update/tests/src/Functional/UpdateContribTest.php, line 86

Class

UpdateContribTest
Tests how the Update Manager module handles contributed modules and themes in a series of functional tests using mock XML data.

Namespace

Drupal\Tests\update\Functional

Code

public function testUpdateContribBasic() {
  $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();
  $this
    ->refreshUpdateStatus([
    'drupal' => '0.0',
    'aaa_update_test' => '1_0',
  ]);
  $this
    ->standardTests();
  $this
    ->assertSession()
    ->pageTextContains('Up to date');
  $this
    ->assertSession()
    ->responseContains('<h3>Modules</h3>');
  $this
    ->assertSession()
    ->pageTextNotContains('Update available');
  $this
    ->assertSession()
    ->linkExists('AAA Update test');
  $this
    ->assertSession()
    ->linkByHrefExists('http://example.com/project/aaa_update_test');

  // Since aaa_update_test is installed the fact it is hidden and in the
  // Testing package means it should not appear.
  $system_info['aaa_update_test']['hidden'] = TRUE;
  $this
    ->config('update_test.settings')
    ->set('system_info', $system_info)
    ->save();
  $this
    ->refreshUpdateStatus([
    'drupal' => '0.0',
    'aaa_update_test' => '1_0',
  ]);
  $this
    ->assertSession()
    ->linkNotExists('AAA Update test');
  $this
    ->assertSession()
    ->linkByHrefNotExists('http://example.com/project/aaa_update_test');

  // A hidden and installed project not in the Testing package should appear.
  $system_info['aaa_update_test']['package'] = 'aaa_update_test';
  $this
    ->config('update_test.settings')
    ->set('system_info', $system_info)
    ->save();
  $this
    ->refreshUpdateStatus([
    'drupal' => '0.0',
    'aaa_update_test' => '1_0',
  ]);
  $this
    ->assertSession()
    ->linkExists('AAA Update test');
  $this
    ->assertSession()
    ->linkByHrefExists('http://example.com/project/aaa_update_test');
}