function UpdateContribTest::testUpdateContribBasic

Same name in other branches
  1. 9 core/modules/update/tests/src/Functional/UpdateContribTest.php \Drupal\Tests\update\Functional\UpdateContribTest::testUpdateContribBasic()
  2. 10 core/modules/update/tests/src/Functional/UpdateContribTest.php \Drupal\Tests\update\Functional\UpdateContribTest::testUpdateContribBasic()
  3. 11.x 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() {
    $project_link = Link::fromTextAndUrl(t('AAA Update test'), Url::fromUri('http://example.com/project/aaa_update_test'))->toString();
    $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->assertText(t('Up to date'));
    $this->assertRaw('<h3>' . t('Modules') . '</h3>');
    $this->assertNoText(t('Update available'));
    $this->assertRaw($project_link, 'Link to aaa_update_test project appears.');
    // 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->assertNoRaw($project_link, 'Link to aaa_update_test project does not appear.');
    // 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->assertRaw($project_link, 'Link to aaa_update_test project appears.');
}

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